Introduction | Language Structure | IB Statements | File System | Comet 32 Runtime | Index |
| Syntax: | RSUB(string-argument, position, length) |
| Discussion: |
The RSUB function returns a substring from the right-hand side of
the specified string-argument.
This function operates on the current length of the string-argument, rather than the defined length. The string-argument may be a string constant, a single-element string variable, a string array element, a string expression, or a string function. The position may be a numeric constant, a single-element numeric variable, a numeric array element, a numeric expression, or a numeric function. This parameter represents the rightmost position of the string-argument. The length may be a numeric constant, a single-element numeric variable, a numeric array element, a numeric expression, or a numeric function. This parameter represents the number of characters to be returned by the RSUB function. Also see SUB. |
| Example 1: |
ZIP$ = RSUB(ADDRESS2$,1,5)This example uses the RSUB function to return the last five characters of data from the variable named ADDRESS2$. The position is set to 1, indicating the right side of the string-argument. The length is set to 5, indicating the number of characters to be returned by the RSUB function. If the value of ADDRESS2$ equals "Sebastopol, CA 95472", then the value of ZIP$ will equal "95472" -- the righthand 5 bytes of the field. |
| Example 2: |
IF RSUB$(ADDRESS2$,1,5) = "95472" THEN PRINT (0) "Sebastopol"This example shows how the RSUB function can be used in-line with an IF statement. In this case, the RSUB function returns the last five characters of the variable named ADDRESS2$ (see Example 1 above). |