STRTOINT
The STRTOINT function is used to convert strings into integer values.
Conversion in the opposite direction, from an integer to a string can be done using the FORMAT function.
Syntax
STRTOINT( STRING string )
Parameters
- string
-
The string to parse as an integer. Trailing and/or leading whitespace will be ignored.
If the string starts with 0x or 0X then it will be interpreted as a hexadecimal value and if it starts with 0b or 0B then it will be interpreted as a binary value.
If the string contains more than just a number to be converted (e.g. "+123"), the function will fail. Instead, pass in the substring to be converted (see the example below).
Errors
If the string cannot be converted to an integer, a runtime error occurs.
Examples
STRING x := "42"; STRING b := "0b1010101"; STRING s := "+123"; PRINT("Decimal: ", STRTOINT(x), "\n"); PRINT("Hex: ", STRTOINT("0x" : x), "\n"); PRINT("Binary: ", STRTOINT(b), "\n"); PRINT("Substring: ", STRTOINT(s[3..1]), "\n");
The output will be:
Decimal: 42 Hex: 66 Binary: 85 Substring: 123
See Also
XJTAG v4.1.100