Basic programming guide – Remote Processing BASIC for the CX-10 Modbus User Manual

Page 14

Advertising
background image

BASIC PROGRAMMING GUIDE

2-5

CHR

Syntax:

CHR(expr)
CHR(string,position)
Where: expr = number from 0 to 255

string = string variable
position = 1 to length of string

Function:

Converts expr to ASCII character or prints string at position

Mode:

Command, run

Use:

PRINT CHR(65)
PRINT CHR($(0),1)

DESCRIPTION

CHR is a dual use operator, similar to ASC. One version converts a numeric expression to an ASCII
character, allowing a variety of string manipulation operations. The second version uses CHR to print
individual characters in an ASCII string. expr is a decimal number and truncates numbers from 0 through
65535. There must be no space between CHR and the left parentheses or an ARRAY SIZE error results.
Although expr can be any integer, printable ASCII characters range from 20H through 7EH (32 through 127).

RELATED

ASC, STRING

ERRORS

BAD ARGUMENT expr can't be truncated to an integer (0 through 65535)
ARRAY SIZE

space between CHR and left parentheses

EXAMPLE

10

STRING 200,20

20

$(1)="1234567890"

30

FOR N=64 TO 80

40

PRINT CHR(N),

50

NEXT

60

PRINT

70

FOR N=1 TO 9

80

PRINT CHR($(1),N),

90

NEXT

RUN
@ABCDEFGHIJKLMNOP
1234567890

Advertising