DI-159 PLC Hardware Manual
StickOS
Debugging Programs
There are a number of techniques you can use for debugging StickOS BASIC programs.
The simplest debugging technique is simply to insert print statements in the program at strategic
locations, and display the values of variables.
A more powerful debugging technique is to insert one or more breakpoints in the program,
with the following statement:
line
stop
When program execution reaches line, the program will stop and then you can use immediate
mode to display or modify the values of any and all variables.
To continue a stopped BASIC program, use the command:
cont
cont
line
An even more powerful debugging technique is to insert one or more conditional breakpoints
in the program, with the following statement:
line
assert
expression
When the program execution reaches line, expression is evaluated, and if it is false (i.e., 0), the
program will stop and you can use immediate mode to display or modify the values of any and
all variables.
Again, to continue a stopped BASIC program, use the command:
cont
cont
line
The most powerful debugging technique, though also the most expensive in terms of program
performance, is to insert a watchpoint expression in the program, with the following statement
line
on
expression
do
statement
The watchpoint expression is re-evaluated before every line of the program is executed; if the
expression transitions from false to true, the watchpoint statement handler runs.
When debugging, the statement handler is typically a "stop" statement, such as:
line
on
expression
do stop
30
Содержание DI-159
Страница 51: ...StickOS DI 159 PLC Hardware Manual 4 is even _ 51...
Страница 76: ...DI 159 Block Diagram 76...
Страница 77: ...Dimensional Drawing 77...