Académique Documents
Professionnel Documents
Culture Documents
Scripts:
Intermediate
Error Trapping
When requesting user input, it is imperative that
the users enter the data in the desired format.
Dropdown, radio buttons, and check boxes
provide the user with limited options. The Edit
Box and ACCEPT() Commands, however, allow
the users to enter data in a free flow manner.
Entering invalid data can cause the script to
crash or produce invalid results. In order to
avoid this, users should engage in a practice
known as Error Trapping.
The Error Trapping Principle
The way an error trap works is that it will repeat a
script until the conditions for acceptable data
are met. This generally means:
1) Define a flag to monitor the conditions.
2) Execute a subscript so long as the conditions
are not met.
3) At the end of the subscript, check to see if the
conditions are met. If they are, then change
the flag ending the script.
Example 1:
While writing a script, you wish to ask the
user for a minimum dollar amount. You
only want numerics, a maximum of one
period, and negative signs.
Script
ASSIGN v_flag = F
DO subscript WHILE v_flag = F
Subscript
V_flag = T