3 - 41 3 - 41
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
(2) Finding the length of a character string
The LEN function is used to find the length of a character string.
10 A$ = "ABCDE"
20 A= LEN (A$)
30 PRINT A
40 END
RUN
5
OK
(3) Converting characters to ASCII code equivalents
Each character used in BASIC has a corresponding ASCII code number.
(See Appendix 4.1)
For example, for alphabet characters, the codes correspond as follows:
[Character]
[Code]
A
65
B
66
:
:
The ASC function and CHR$ function are used for conversion between ASCII
codes and characters.
Example
OK
PRINT ASC( " A" )
65
OK
PRINT CHR$(65)
A
OK
"A"
ASC
CHR$
65
Character
Value
• Only character constants, character arrays, or character conversion can be specified
inside the parentheses of an ASC function.
Only numeric constants, numeric arrays, or variables can be specified inside
the parentheses of a CHR$ function.
• Specifying number 31 or less in the parentheses in a CHR$ function will produce
control characters described in Section 3.13.1.
• Full-byte characters cannot be used with the ASC 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...