Rockwell Automation 1771-DB BASIC MODULE User Manual
Page 126

Chapter
Expressions, Variables and Operators
9
9 -16
CHR
Use the CHR operator to convert a numeric expression to an ASCII
character.
>PRINT CHR(65)
Result:
A
Like the ASC operator, the CHR operator also selects individual characters
in a defined ASCII string. The expressions within the parentheses that
follow the CHR operator have the same meaning as the expressions in the
ASC operator.
>NEW
>1 REM EXAMPLE PROGRAM
>5 STRING 1000,40
>10 $(1) = “THE BASIC MODULE”
>20 FOR I = 1 TO 16 : PRINT CHR($(1),I),: NEXT I
READY
>RUN
THE BASIC MODULE
READY
>
Unlike the ASC operator, you cannot assign the CHR operator a value.
A statement such as CHR ($(1),1)= H is invalid and generates an
ERROR:
BAD SYNTAX
message,. When this error occurs the BASIC module enters
Command mode. Use the ASC operator to change a value in a string, or
use the string support CALL 65 (page 12 -64) - replace string in a string.
Important: Use CHR only in a PRINT statement (page 11 -29).
You cannot use the CHR in a DATA statement (page 11 -6).