CRE Programmer's Guide

String and Memory Block Functions
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
8-29
Strtol
Considerations
str must be terminated by a zero (null) byte to stop the scan.
Leading white space is skipped.
str is a string of digits, optionally preceded by a sign.
The functions stop scanning if they encounter an unrecognized character.
Example
STRING .s[0:7] := ["52431",0];
STRING .scanend;
REAL(64) d;
! d gets 52431.
! @scanend gets @s[5]
d := CRE_Strtod_(s, @scanend );
Strtol
The Strtol functions convert a string of characters to a 32-bit integer using a specified
base.
str
is a pointer to the string to convert.
end_scan
is the address within str where the conversion ended. The pointer returned
through
end_scan points to the first unrecognized character.
base
specifies the radix of the digits at str. It must be in the range:
0 <= base <= 36
If base is zero, the leading characters of str determine the radix:
°
0X or 0x indicates a hexadecimal number.
°
0 indicates an octal number.
°
1 through 9 indicate a decimal number.
INT(32) PROC CRE_Strtol_( str, end_scan, base );
STRING .str; ! in
INT .end_scan; ! out
INT base; ! in TNS only
INT(32) PROC CRE_StrtolX_( str, end_scan, base );
STRING .EXT str; ! in
INT(32) .EXT end_scan; ! out
INT base; ! in TNS only