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

BASIC PROGRAMMING GUIDE
2-2
ASC
Syntax:
ASC(ASCII character)
ASC(string,position expr)
Where: ASCII character = number from 0 to 255
string = any valid string variable
position expr = 1 to length of string
Function:
Returns or sets the integer value of an ASCII character or the character in string at position expr.
Mode:
Command, run
Use:
PRINT ASC(C)
ASC($(3),1)=48H
C = ASC($(0),P)
DESCRIPTION
The ASC operator either sets or returns the value of an ASCII character. Use ASC to evaluate, change or
manipulate individual characters in a string.
The first syntax returns the value of an ASCII character. If ASCII character were the letter 'B', a 66 is
returned. Basic converts any lower case variable symbols to upper case. Lower case characters must be put
into a string to be evaluated.
The second syntax, shown under Use, sets a character in a string to a specific value. This is useful when you
want to manipulate individual characters in a string.
The third syntax returns a value in string at position expr. This form is useful when you want to evaluate
individual characters in a string, such as generating a checksum.
RELATED
CHR, STRING
ERROR
SYNTAX
Attempt to convert an improper value.
EXAMPLE
The following example prints ASCII values from the string $(0). The first 3 characters are modified at lines
70 to 90. The result is then printed.
10
STRING 200,20
20
$(0)="abc123"
30
FOR N=1 TO 6
40
PRINT ASC($(0),N),
50
NEXT
60
70
FOR N=1 TO 3
80
ASC($(0),N)=65+N
90
NEXT
100
PRINT $(0)
READY
>RUN
97
98
99
49
50
51
BCD123