Programming 636
• To confirm that a loop is executed the correct number of times, display the counter
variable or the values in the conditional test.
• To confirm that a subroutine is executed, display messages such as
Entering
subroutine
and Exiting subroutine at the beginning and end of the subroutine.
Error-Handling Commands
Error-Handling CommandsError-Handling Commands
Error-Handling Commands
Example: Using Alternative Approaches
Example: Using Alternative ApproachesExample: Using Alternative Approaches
Example: Using Alternative Approaches
The example in the Previews module shows a program that prompts the user to enter an
integer, sums all integers from 1 to the entered integer, and displays the result. This
section gives several approaches that you can use to achieve the same goal.
Command Description
Try...EndTry Defines a program block that lets the program execute a
command and, if necessary, recover from an error
generated by that command.
ClrErr Clears the error status and sets the error number in system
variable Errornum to zero.
PassErr Passes an error to the next level of the Try...EndTry block.