Debugging
Debugging commands are essential to find programming errors. They help with inspecting programs and data, to pause a program, to find out why a program takes too much time, and much more. Logo can pause because of several reasons:
-
The PAUSE command has been executed
-
A runtime error has occured
-
The PAUSE button has been clicked
-
A STEPped element has triggered a pause
BACKTRACE
Also: BT
Prints the list of nested procedure calls; no inputs.
Syntax
BACKTRACE
Description
BACKTRACE prints the list of currently executing procedures.
BPCLEAR
Deletes all breakpoints; no inputs.
Syntax
BPCLEAR
Description
BPCLEAR deletes all breakpoints in all procedures.
CONTINUE
Also: CO
Ends a pause; no inputs.
Syntax
CONTINUE
Description
CONTINUE ends a pause. A Logo program can pause because it is stepped (see STEP), the PAUSE command has been executed, or if Logo has hit a runtime error (if the PREFS property PREFS/DEBUGGER is set to TRUE).
If this command is used when the debugger is not active, it does nothing.
PAUSE
Pauses a procedure; no inputs.
Syntax
PAUSE
Description
PAUSE temporarily halts the execution of a procedure. PAUSE makes it possible to check variables or change the environment during the execution of a procedure. To resume execution of the procedure, press the Continue button or type CO or CONTINUE. To return to toplevel, press the STOP button or type TOPLEVEL.
If this command is used outside of a procedure, it does nothing.
It is more convenient to set a breakpoint in the editor by clicking the line number of the line where you want Logo to pause.
Examples
TO SQUAREDRAW FORWARD 60 RT 90 PAUSE REPEAT 3 [FD 60 RT 90] END Result: SQUAREDRAW defined SQUAREDRAW Result: Program paused
STEP
Turns on stepping for the given elements; one input.
Syntax
STEP procedurename
STEP [procedurename1 ...]
STEP contents-list
Description
STEP turns the stepping on for the given elements. If the input is a list or a word, stepping is turned on for the given procedures. If the input is a structured contents list, stepping is turned on for the given procedures, names and properties.
When a procedure is being stepped, Logo pauses at the beginning of that procedure and enters debug mode. This is the same as starting the procedure definition with a PAUSE command.
When a name is being stepped, Logo pauses whenever the value of the name is changed, or the name is erased, and enters debug mode. Note that the name must be a global name; local names cannot be stepped.
When a property list is being stepped, Logo pauses whenever any value of the property is changed, or a property is erased, and enters debug mode.
STEPPED
Outputs a structured contents list of all stepped elements; no inputs.
Syntax
STEPPED
Description
STEPPED outputs a structured contents list of all stepped, non-empty elements. For an explanation of stepping see STEP.
STEPPED?
Also: STEPPEDP
Outputs TRUE if the element described by its input is stepped; one input.
Syntax
STEPPED? name-or-list
Description
STEPPED? outputs TRUE if the element described by its input is stepped. If the input is a list or a structured contents list, STEPPED? outputs the stepped state of the first non-empty element of the list.
TRACE
Turns on tracing of the given elements; one input.
Syntax
TRACE procedurename
TRACE [procedurename1 ...]
TRACE contents-list
Description
TRACE turns the tracing on for the given elements. If the input is a list or a word, tracing is turned on for the given procedures. If the input is a structured contents list, tracing is turned on for the given procedures, names, and properties.
When a procedure is being traced, Logo prints a message to the Listener panel every time the procedure is entered or left. When entering the procedure, the call is printed along with the procedure arguments. When the procedure leaves, the message contains the value that the procedure outputs, if any.
When a name is being traced, Logo prints a message to the Listener panel whenever the value for the name is changed along with the new value, or when the value is erased. Also, Logo prints a message if a local variable hides a global variable (or a local variable in a calling procedure) that has the same name.
When a property list is being stepped, Logo prints a message to the Listener panel whenever any value of the property is changed, or a property is erased, and enters debug mode.
Note that the global variable :TRACE takes precedence over the settings of this command. Also, TRACE does not display each line of a procedure as it is being executed, but :TRACE does.
TRACED
Outputs a structured contents list of all traced elements; no inputs.
Syntax
TRACED
Description
TRACED outputs a structured contents list of all traced, non-empty elements. For an explanation of tracing see TRACE.
TRACED?
Also: TRACEDP
Outputs TRUE if the element described by its input is traced; one input.
Syntax
TRACED? name-or-list
Description
TRACED? outputs TRUE if the element described by its input is traced. If the input is a list or a structured contents list, TRACED? outputs the traced state of the first non-empty element of the list.
UNSTEP
Turns off stepping of the given elements; one input.
Syntax
UNSTEP procedurename
UNSTEP [procedurename1 ...]
UNSTEP contents-list
Description
UNSTEP turns the stepping off for the given elements. If the input is a list or a word, stepping is turned off for the given procedures. If the input is a structured contents list, stepping is turned off for the given procedures, names and properties. For an explanation of stepping, see STEP.
UNTRACE
Turns off tracing of the given elements; one input.
Syntax
UNTRACE procedurename
UNTRACE [procedurename1 ...]
UNTRACE contents-list
Description
UNTRACE turns the tracing off for the given elements. If the input is a list or a word, tracing is turned off for the given procedures. If the input is a structured contents list, tracing is turned off for the given procedures, names, and properties. For an explanation of tracing, see TRACE.