If a condition save file for tank loading has been written using
the WRITE (LOADS) command, but one of its tanks has later been removed
from the vessel geometry, then a variety of fatal error messages
would be triggered when running the save file, such as:
"No such
part" - trapped by the PART command for missing part (error#
911). "No part name" - trapped by LOAD, CONT, TYPE etc.
if no part (error# 912); "Bad part name" - trapped by
LOAD, CONT, TYPE etc. for bad part (error# 913).
Each of these
three error conditions may be recognized by its unique error number,
which is assigned to the system variable ERROR after error detection.
If an ESC macro has been defined before running the condition save
file, this macro will be executed automatically following an error,
which permits special handling of these specific ERROR numbers,
such as ignoring them or reporting them as non-fatal warnings.
Here is a sample
ESC macro which ignores all missing-part errors in loading condition
save files, while treating other errors as fatal:
SET ERROR=-3
MACRO ESC
IF {ERROR}>=911 THEN IF {ERROR}<=912 THEN PART OFF | SET ERROR=-3
| EXIT
ERROR
/
Let's look at
this macro in more detail to understand why it works. Setting the
ERROR variable to -3 causes execution to continue with the next
line after any error, without reporting it or waiting. But before
continuing, the ERROR variable is set equal to any special number
for the error (or zero if none), and any ESC macro is executed.
While running
the condition save file, if a PART command is encountered for a
missing part, then the ERROR variable is set to 911 and the ESC
macro is executed. Since 911 is between 911 and 912, the ESC macro
first turns off the current part selection, which is very important
so that upcoming LOAD, CONT, etc. commands won't affect the wrong
part. Then the ERROR variable is set back to -3, and the ESC macro
exits to continue save file execution.
The condition
save file will normally contain a series of LOAD, CONT, etc. commands
following the missing PART command. Since no part is selected (due
to PART OFF in the ESC macro), each of these commands triggers an
error which sets the ERROR variable to 912. The ESC macro treats
912 errors the same as 911 errors, turning PART OFF, resetting ERROR
to -3, and continuing.
If any other
error is encountered in the condition save file, the ERROR variable
value would not be 911 or 912, so the IF line would be bypassed
and the ERROR command would be reached. The ERROR command reports
and reprocesses the last error detected - and since the ERROR variable
no longer has a negative value, the fatal error ends condition save
file execution.
Here is another
sample ESC macro which reports missing-part errors with non-fatal
warnings, but ignores "No part name" errors in subsequent
LOAD, CONT, TYPE, etc. commands following each missing-part error:
SET ERROR=-3
MACRO ESC
VARIABLE SKIPERR
IF {ERROR}>=911 THEN IF {ERROR}<=912 THEN SET SKIPERR=1
IF {ERROR}=911 THEN SET ERROR=-2 | ERROR
IF {SKIPERR}=1 THEN PART OFF | SET ERROR=-3 | EXIT
ERROR
/
This ESC macro
is similar to the previous version except a missing-part error (ERROR
number 911) receives special handling, setting the ERROR variable
to -2 and reprocessing the error. Setting ERROR to -2 causes "No
such part" to be reported and to wait before continuing. (Note
that ERROR set to -1 could have been used instead to continue without
waiting.) After reporting the missing-part error command, the current
part is turned off, the ERROR variable is reset to -3, and condition
save file execution resumes.
|