F$INTEGER(): Difference between revisions
Created page with "'''F$INTEGER()''' is a lexical function that returns the integer equivalent of the result of the specified expression. =Format= F$INTEGER (expression)..." |
No edit summary |
||
| Line 30: | Line 30: | ||
$ write sys$output f$integer("yellow") | $ write sys$output f$integer("yellow") | ||
1</pre> | 1</pre> | ||
[[Category: Lexical Functions]] | |||
Latest revision as of 05:48, 15 January 2019
F$INTEGER() is a lexical function that returns the integer equivalent of the result of the specified expression.
Format
F$INTEGER (expression)
Argument
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.
Example
$ write sys$output f$string(5)
5
$ write sys$output f$integer("")
0
$ write sys$output f$integer("a")
0
$ write sys$output f$integer("hello")
0
$ write sys$output f$integer("true")
1
$ write sys$output f$integer("false")
0
$ write sys$output f$integer("yes")
1
$ write sys$output f$integer("y")
1
$ write sys$output f$integer("yellow")
1