3 - 22 3 - 22
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
Use the RESTORE instruction in order to use values of the same DATA instruction
again. The following illustrates what happens when the RESTORE instruction is used.
A value in the DATA
instruction in line 10 is
used again by using the
RESTORE instruction.
7
A
8
B
7
C
10 DATA 7, 8
20 READ A, B
30 RESTORE
40 READ C
…
Line numbers can be specified when using the RESTORE instruction. The following
illustrates what happens when a line number is specified.
The value of the DATA
instruction in line 20 is
used again by the
RESTORE instruction.
7
A
8
B
8
C
10 DATA 7
20 DATA 8
30 READ A, B
40 RESTORE 20
50 READ C
REMARK
The READ instruction can use arrays instead of variables that read data. The
following program is an example where data is assigned to A$(0) through A$(2). Try
executing this block.
10 DIM A$(2)
20 READ A$(0), A$(1), A$(2)
30 PRINT A$(0), A$(1), A$(2)
40 DATA 51H, PC, A
RUN
51H PC A
OK
"51H"
A$(0)
"PC"
A$(1)
"A"
A$(2)