xLadder user manual-V2.0.0.6

6.5.16 String to integer

Input/output Operand

Data type

IN

VB,constant string, LB, *VD, *LD, *AC

String

INDX

VB, IB, QB, MB, SB, SMB, LB,constant, AC,*VD, *LD, *AC Byte

OUT

VW, IW, QW, MW, SW, SMW, LW, T, C, AQW, AC, *VD, *LD, *AC Integer

S - I : The instruction converts the string value “ IN ” to the

integer value stored in the OUT, starting with the offset

INDX location.

ASCII constant string data type format :

String is a series of characters, each character is stored as a byte.The first byte of a

string defines the length of the string, that is the number of characters.If a constant

string is entered directly into the program editor or data block, the string must start

and end with double quotation marks ("string constant").

The following memory map shows the format of the string data type.The length of a

string can be between 0 and 254 characters.The maximum length of the string is 255

bytes. String length

Character 1

Character 2

Character 5

Character 254

Character

Character

..................................

3

4

Byte 0

Byte 1

Byte 2

Byte 3

Byte 4

Byte 5

Byte 254

INDX value is typically set to 1,starting conversion from the first character of the

string.INDX value can be set to other values.This method can be used when the input

string contains characters that are not required to be converted.For example, if the

input string is “ Temperature: 77.8 ” ,you can set INDX value 13 to skip the

characters "Temperature:".

When the end of the string is reached or when the first invalid character is found, the

conversion is terminated.Invalid character is any character other than number (0 - 9).

107

Made with FlippingBook - Online magazine maker