Previous | Contents | Index |
Returns the integer equivalent of the result of the specified expression.
F$INTEGER (expression)
expression
Specifies the expression to be evaluated. Specify either an integer or a character string expression.If you specify an integer expression, the F$INTEGER function evaluates the expression and returns the result. If you specify a string expression, the F$INTEGER function evaluates the expression, converts the resulting string to an integer, and returns the result.
After evaluating a string expression, the F$INTEGER function converts the result to an integer in the following way. If the resulting string contains characters that form a valid integer, the F$INTEGER function returns the integer value. If the string contains characters that do not form a valid integer, the F$INTEGER function returns the integer 1 if the string begins with T, t, Y, or y. The function returns the integer 0 if the string begins with any other character.
$ A = "23" $ B = F$INTEGER("-9" + A) $ SHOW SYMBOL B B = -923 Hex=FFFFFC65 Octal=176145 |
This example shows how to use the F$INTEGER function to equate a symbol to the integer value returned by the function. In the example, the F$INTEGER function returns the integer equivalent of the string expression ("--9" + A). First, the F$INTEGER function evaluates the string expression by concatenating the string literal "--9" with the string literal "23". Note that the value of the symbol A is substituted automatically in a string expression. Also note that the plus sign (+) is a string concatenation operator because both arguments are string literals.
After the string expression is evaluated, the F$INTEGER function converts the resulting character string ("--923") to an integer, and returns the value --923. This integer value is assigned to the symbol B.
Previous | Next | Contents | Index |