Chr([expr]) – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual
Page 36

Publication 1746-RM001A-US-P
3-14 Expressions and Operators
CHR([expr])
Use the CHR operator to convert a numeric expression to an ASCII character.
Like the ASC operator, the CHR operator also selects individual characters in a
defined ASCII string.
>NEW
>1
REM EXAMPLE PROGRAM
>5
STRING 1000,40
>10 $(1) = “The module”
>20 FOR I = 1 TO 16 : PRINT CHR($(1),I),: NEXT I
READY
>RUN
The module
READY
>
In the example above, the expressions contained within the parentheses, following
the CHR operator have the same meaning as the expressions in the ASC operator.
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, causing the module to go into Command mode. Use the ASC operator to
change a value in a string, or use the string support CALL routine – replace string
in a string.
Example
Result
>PRINT CHR(65)
A
IMPORTANT
Use the CHR function only in a print statement. You cannot use
the CHR operator in a DATA statement.