2-271
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Data Type Conversion Instructions
2
STRING_TO_** (Text String-to-Integer Conversion Group)
The following example for the STRING_TO_DINT instruction is for when In is ‘123456789’.
The valid range of In depends on the data type of Out as shown below:
* Any blank characters (‘ ’) at the beginning of the text string, any zeros at the beginning of the text string, and any
underbars (‘_’) in the text string are not included in the number of bytes.
• To convert a text string to a hexadecimal number, use a STRING_TO_** (Text String-to-Bit String
Conversion Group) instruction (page 2-272).
• To convert an integer to a text string, use a **_TO_STRING (Integer-to-Text String Conversion Group)
instruction (page 2-253).
• Always use the correct instruction name for the data type of Out.
• If the value of In is ‘−0’, the value of Out is 0.
• An error occurs in the following cases. ENO will be FALSE, and Out will not change.
• The text string in In does not express a number.
• The conversion result exceeds the valid range of the data type of Out.
• The text string in In does not end in a NULL character.
Data type of Out Valid range of In (maximum number of bytes)*
USINT 4 bytes (three single-byte alphanumeric characters plus the
final NULL character)
UINT 6 bytes (five single-byte alphanumeric characters plus the final
NULL character)
UDINT 11 bytes (10 single-byte alphanumeric characters plus the final
NULL character)
ULINT 21 bytes (20 single-byte alphanumeric characters plus the final
NULL character)
SINT 5 bytes (four single-byte alphanumeric characters plus the final
NULL character)
INT 7 bytes (six single-byte alphanumeric characters plus the final
NULL character)
DINT 12 bytes (11 single-byte alphanumeric characters plus the final
NULL character)
LINT 21 bytes (20 single-byte alphanumeric characters plus the final
NULL character)
Additional Information
Precautions for Correct Use
abc:=STRING_TO_DINT(‘123456789’);
LD ST
abc
‘123456789’
STRING_TO_DINT
EN ENO
In
‘123456789’
STRING data
123456789
DINT data
In
Out=abc