13: S
CRIPTS
13-30 S
MART
AXIS P
RO
/L
ITE
U
SER
'
S
M
ANUAL
FT9Y-B1378
Converting -12345 (when the data type is I (integer))
Converting 1234567890 (when the data type is D (double word))
Converting -1234567890 (when the data type is L (long))
Example 7.21 Convert string to decimal
Script
Operation Description
Converts the stored string starting at D0200 to a decimal and stores the result in D0100.
The number of digits that can be converted is the maximum number of digits for each data type with added sign.
If the string to convert contains a NULL or characters that cannot be converted to numeric values, the string is converted up to
that character.
Notes:
• This function can be used with data types W (word), I (integer), D (double word), and L (long).
• The NULL terminating character (0x00) is added to the end of the string.
Setting the string "1234" (when the data type is W (word))
Device
Stored value
Device Stored value Upper byte Lower byte
D0200 -12345 D0100 '-' = 0x2D '1' = 0x31
D0101 '2' = 0x32 '3' = 0x33
D0102 '4' = 0x34 '5' = 0x35
D0103 0x00 0x00
Terminating character
Device
Stored value
Device Stored value Upper byte Lower byte
D0200
1234567890
D0100 '1' = 0x31 '2' = 0x32
D0201 D0101 '3' = 0x33 '4' = 0x34
D0102 '5' = 0x35 '6' = 0x36
D0103 '7' = 0x37 '8' = 0x38
D0104 '9' = 0x39 '0' = 0x30
D0105 0x00 0x00
Terminating character
Device
Stored value
Device Stored value Upper byte Lower byte
D0200
-1234567890
D0100 '-' = 0x2D '1' = 0x31
D0201 D0101 '2' = 0x32 '3' = 0x33
D0102 '4' = 0x34 '5' = 0x35
D0103 '6' = 0x36 '7' = 0x37
D0104 '8' = 0x38 '9' = 0x39
D0105 '0' = 0x30 0x00
Terminating character
[D0100] = ASCII2DEC([D0200]);
Device
Stored value
Upper byte Lower byte Device Stored value
D0200 '1' = 0x31 '2' = 0x32 D0100 1234
D0201 '3' = 0x33 '4' = 0x34
D0202 0x00 0x00
Terminating character