3 - 42 3 - 42
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
(4) Conversion of numbers and characters
The following calculation cannot be performed even if the character string is fully
comprised of numbers.
Example
OK
A$= " 12345"
OK
B=1156
OK
PRINT A$+B
Type mismatch
OK
The VAL function is used when treating a character string comprised of only
numbers as a numeric value. The VAL function converts character strings to
numeric values.
Example
Continued from Example above
A=VAL(A$)
OK
PRINT A+B
13501
OK
Conversely, when handling numeric values as character strings, the STR$
function is used. The STR$ function converts numeric values to character strings.
Example
Continued from Example above
C$=STR$(A+B)
OK
PRINT RIGHT$(C$, 3)
501
OK
Here is a summary of the above points.
"123"
VAL
STR$
123
Characters
Numbers
An Illegal Function Call error will be generated if anything other than
numbers, +, -, E, or • are included in the character string that is to
be converted by the VAL function.
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...