10- 3 10- 3
MELSEC-Q
10 Program Debugging
(3) PRINT instruction and LET instruction
The targets of these instructions are the values of variables and arrays used in a
program at the time it was paused by the above-mentioned STOP instruction.
Execute the PRINT instruction to display the values of variables etc. on the
screen while the program is paused.
Execute the LET instruction to forcefully change the values of variables etc. while
the program is paused.
10 DIM IN$(2)
RUN
20 FOR I%=0 TO 2
? MITUBISHI
30 INPUT IN$(I%)
? MELSEC
40 NEXT I%
? AD51H
50 STOP
Break in 50
60 FOR I%=0 TO 2
OK
70 PRINT IN$(I%)
PRINT IN$(0)
80 NEXT I%
MITUBISHI
90 END
OK
IN$(0) = "Mitsubishi"
OK
PRINT IN$(2)
AD51H
OK
IN$(2)="BASIC"
OK
CONT
Mitsubishi
MELSEC
BASIC
OK
Use the following instructions in a BASIC program to make debugging easier.
• ON ERROR GOTO and RESUME instructions
Use these instructions to prevent the program from being stopped due to error
occurrence.
• ERROR instruction
Use this instruction to generate an error to check whether or not the flow of the
program execution is correct.
• ERR and ERL functions
Use these instructions to check the error code of an error that just occurred
and the line number where the error occurred, respectively.