
62
Processing Character Strings
Section 5-1
5-1
Processing Character Strings
Example
The following code will find the position of “STX” in response data R$, retrieve
the characters from there to “ETX” and store them in A$.
Example
If the two characters after the fourth character from the start of response data
A$ are 00, The following line will jump to line 1000 as a correct response.
5-2
Processing Bits
Note
1.
One bit will be set without changing the other bits.
2.
When transferring bit data to the PC, turn ON/OFF the required bit with
these commands and then use the PC PUT command.
5-3
Processing Receive Buffers
Process
Programming
Retrieving n characters from beginning of
A$
B$ = MID$(A$, 1, n) or
B$ = LEFT$(A$, n)
Retrieving n characters from character
number m
B$ = MID$(A$, m, n)
Retrieving n characters from end of A$
B$ = RIGHT$(A$, n)
Searching for character string from char-
acter number m in A$ and getting position
of first character
B = INSTR(m, A$,
character_string
)
Getting number of characters in A$
B = LEN(A$)
Converting character string A$ to numeric
value
B = VAL(A$)
Converting numeric value B to character
string A$
A$ = STR$(B)
100
STX$ = CHR$(&H02)
Generate STX.
110
ETX$ = CHR$(&H03)
Generate ETX.
120
A = INSTR(1, R$, STX$)
Find the position of STX$ in R$.
130
B = INSTR(1, R$, ETX$)
Find the position of ETX$ in R$.
140
A$ = MID$(R$, A, B–A+1)
Retrieve the character string from STX$ to
ETX$ in R$ and store it in A$.
150
IF MID$(A$,4,2)=“00” THEN 1000
Process
Programming
Turning ON/OFF 1 bit of a variable.
BITON A%, 3
(Turns ON bit 3 of variable A%.)
BITOFF A%, 3
(Turns OFF bit 3 of variable A%.)
Process
Programming
Obtaining the number of characters in the
receive buffer
A = LOC(1)
(Stores the number of characters held in
the communications port #1 receive
buffer in A.)
Executing a process if the number of
characters in a receive buffer is not 0
(i.e.,if it is not empty)
100 A = LOC(1)
110 IF A<>0 THEN 200
200
Process A
Содержание C200H-ASC11
Страница 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Страница 2: ...iv...
Страница 4: ...vi...