Application Guide

Note: Mode changes made within a function or program definition do not persist
outside the function or program.
Setting a Mode
1. Position the cursor where you want to insert the setMode function.
2. From the Mode menu, click the mode to change, and click the new setting.
The correct syntax is inserted at the cursor location. For example:
setMode(1,3)
Debugging Programs and Handling Errors
After you write a function or program, you can use several techniques to find and
correct errors. You can also build an error-handling command into the function or
program itself.
If your function or program allows the user to select from several options, be sure to
run it and test each option.
Techniques for Debugging
Run-time error messages can locate syntax errors but not errors in program logic. The
following techniques may be useful.
Temporarily insert Disp commands to display the values of critical variables.
To confirm that a loop is executed the correct number of times, use Disp to display
the counter variable or the values in the conditional test.
To confirm that a subroutine is executed, use Disp to display messages such as
“Entering subroutine” and “Exiting subroutine” at the beginning and end of the
subroutine.
To stop a program or function manually,
- Windows®: Hold down the F12 key and press Enter repeatedly.
- Mac®: Hold down the F5 key and press Enter repeatedly.
- Handheld: Hold down the c key and press · repeatedly.
Error-handling Commands
Command Description
Try...EndTry Defines a block that lets a function or program execute a command
and, if necessary, recover from an error generated by that command.
ClrErr Clears the error status and sets system variable errCode to zero. For an
example of using errCode, see the Try command in the Reference
Guide.
Getting Started with the Program Editor 503