7 APPLICATION INSTRUCTIONS
7.11 Character String Processing Instructions
557
7
■VAL
• Converts character strings stored in the device numbers starting from that designated at (S) to BIN 16-bit data, and stores
the number of digits and BIN data in (D1) and (D2). For conversions from character strings to BIN, all data from the device
number designated by (S) to the device number where "00H" is stored will be processed as character strings.
For example, if the character string "-123.45" is designated for the area starting from (S), the operation result would be stored
at (D1) and (D2) in the following manner:
• The total number of characters that can be designated as a character string at (S) is from 2 to 8.
• From 0 to 5 characters from the character string designated at (S) can become the decimal fraction part. However, this
number must not exceed the total number of digits minus 3.
• The range of the numerical character string that can be converted to BIN value is from -32768 to 32767, ignoring a decimal
point. Numerical value character strings, excluding the sign and the decimal point, can be designated only within the range
from "30H" to "39H". The value ignoring a decimal point means:
"-12345.6" "-123456"
• The sign "20H" will be stored if the numerical value is positive, and the sign "2DH" will be stored if it is negative.
• "2EH" is set for the decimal point.
• The total number of digits stored at (D1) amounts to all characters expressing numerical values (including signs and
decimal points). The characters following the decimal point stored at (D1)+1 include the number of characters from "2EH"
(.) onward. The BIN data stored at (D2) is the character string ignoring the decimal point that has been converted to BIN
data.
• In cases where the character string designated by (S) contains "20H" (space) or "30H" (0) between the sign and the first
numerical value other than "0", these "20H" and "30H" are ignored in the conversion into a BIN value.
.
Sign
1st
char-
acter
2nd
char-
acter
7th
char-
acter
Total number
of digits
Number of digits
in decimal fraction
Integer value
ignoring decimal
point
+1
BIN 16 bits
Indicates the end of character string
ASCII code for the sign
ASCII code for the 1st character
ASCII code for the 2nd character
ASCII code for the 3rd character
b15 b8b7 b0
ASCII code for the 4th character
00
H
ASCII code for the 5th character
ASCII code for the 6th character
ASCII code for the 7th character
+4
+3
+2
+1
D1
D2
S
S
S
S
S
D1
.
7
2
1 2 3 4 5
+1
2D
H
( )31
H
(1)
32
H
(2)33
H
(3)
b15 b8 b7 b0
2E
H
(.)34
H
(4)
35
H
(5)00
H
+3
+2
+1
123 4 5
S
S
S
S
D2
D1
D1
8
2
Total number of digits
Number of digits
in decimal fraction
BIN data
12
Ignored
3
.4
5
12
3
4
5
7
4
Total number of digits
Number of digits
in decimal fraction
BIN data
0
.
Ignored
00
12
12
Sign