Debugging Scripts

If a script is not behaving as you expect, you may find it helpful to test the script using one or both of these techniques:

Single-Stepping through a Script

To allow single-stepping, first use the debug script command. Before starting the script you want to test, enter the command:
 
debug script true

While debug script is true, single-stepping can be activated.

After turning on debug script, enter the go command to start the script you want to test. The script will execute normally until you press the pause key or until a haltpoint command is encountered within the script. Single-stepping will then begin.

Note The debug script command allows single-stepping, but single-stepping does not actually begin until you press the pause key or until a haltpoint command is encountered in a script.

When single-stepping is activated, only one command from the script will execute, then the execution of the script will stop until you enter the command:
 

sstep

or press the pause key again. Each sstep command or press of the pause key will cause the next single command from the script to execute. While the script is paused, you can enter your own Autolog commands. The show and debug commands can be useful for displaying diagnostic information to determine why a particular command is not behaving as you expect.

Single-stepping will continue until a resume command is encountered in a script or until you enter the command:
 

debug script false
 

The haltpoint and resume Commands

You can put haltpoint and resume commands into your scripts for diagnostic purposes. The haltpoint command marks the place where you want single-stepping to begin, and the resume command marks the place where you want single-stepping to end. Because single-stepping is not activated until you turn on debug script, the haltpoint and resume commands will not affect normal script execution until you also turn on debug script. When designing complex scripts, you may find it helpful to add haltpoint and resume commands at the beginning and end of sections of the script that you may need to single-step through later. These commands will not affect normal execution when debug script is turned off, but they can make debugging easier when you turn debug script on.