The chr operator – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 111

Advertising
background image

Operating Functions

Chapter 5

5–74

The CHR() operator converts a numeric expression to an ASCII character.

Example:

uPRINT CHR(65)

A

Like the ASC() operator, the CHR() operator also selects individual
characters in a defined ASCII string.

Example:

u5 STRING 1000,40

u10 $(1)=“The BASIC Module”

u20 FOR I=1 TO 16 : PRINT CHR($(1),I), : NEXT I

u30 PRINT: FOR I=16 TO 1 STEP -1

u40 PRINT CHR($(1),I), : NEXT I

uRUN

The BASIC Module

eludoM CISAB ehT

In the above example, the expressions contained within the parenthesis,
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 a
BAD SYNTAX ERROR. Use the ASC() operator to change a value in a
string, or use the string support call routine – replace string in a string. See
Section 5.10.3 below titled, “String Support Calls” for more information.

Important: Use the CHR() function only in a print statement.

5.10.2.1
Clearing the Screen on an Allen-Bradley Industrial Terminal

Refer to Appendix B at the rear of this manual. In “Column 1” under
”DEC”, you find that 12 equals ASCII FF (form feed). Type PRINT
CHR(12) to clear the industrial terminal screen with a form feed.

5.10.2
The CHR Operator

Advertising