10 - 1 10 - 1
MELSEC-Q
10 Program Debugging
10
10 PROGRAM DEBUGGING
Program debugging refers to the operation of checking whether an edited program will run
correctly and revise the program so that it runs correctly. (Debug = removing the bugs)
This section shows the sequence of program debugging and the instructions used in
debugging.
10.1 Sequence of Debugging Programs Executed Simultaneously in Multitasking
When executing multiple programs simultaneously (parallel operation in multitasking),
program debugging is generally performed in the following sequence.
1) Single debugging
• • • •
Execute the programs one at a time, and check each
program to see if it runs properly while specifying
various conditions that change the flow of execution.
2) Combination
debugging
• • • •
Group the programs together in several groups,
each consisting of multiple programs related to the
execution of one process.
Next, execute multiple programs in one group at a
time according to the specifications and check to
see if each program runs properly.
3) Overall debugging
• • • •
Execute all the programs according to the
specifications and check to see if each program
runs properly.
If each program runs according to the
specifications in an overall debugging, then the
debugging is complete.
10.2 Instructions Used when Debugging Programs
The following are typical instructions used when debugging BASIC programs.
See Chapter 11 for details on each instruction.
(1) TRON and TROFF instructions
The TRON instruction is used to follow the program flow. When the TRON
instruction is executed, the line numbers of lines that have been executed are
shown enclosed in square brackets. This makes it easy to see how the flow
branches due to the IF~GOTO instruction and how the instructions are repeated
due to the FOR~NEXT instruction.
Execute the TROFF instruction to stop the line number display.
10 C=10
RUN
20 FOR I=1 TO 3
[60][70][80] 1 14
30 C=C+1
[90][70][80] 2 15
40 NEXT I
[90][70][80] 3 16
50 TRON
[90][100] 17
60 FOR I=1 TO 3
OK
70 C=C+1
80 PRINT I;C
90 NEXT I
100 TROFF
110 C=C+1
120 PRINT C
130 END