Skip to content

ESCAPE WHEN

Conditional Escape from Program Execution

This directive causes an escape from the program when a specified condition is met.

ESCAPE WHEN condition
condition
is a relational, Boolean, and/or logical expression used to establish a true or false condition.

This directive cannot be executed from Thoroughbred Basic Console Mode. It must be in a program.

The directive must be executed for the conditional to be in effect.

The conditional is checked after each directive is executed.

ESCAPE WHEN is only valid for the program in which it resides. It is not valid for any programs called by the program that contains the ESCAPE WHEN.

Once the ESCAPE WHEN condition is met, Thoroughbred Basic does not continue to process any other ESCAPE WHEN conditions.

Only one ESCAPE WHEN can be in effect at a time. Executing an ESCAPE WHEN after one has already been executed supersedes the first one. To get multiple conditions, use connecting OR operators.

The ESCAPE WHEN directive is a debugging tool. Including this directive slows program execution.

The following program:

00010 REM PROGNAME
00020 ESCAPE WHEN I=3 OR I=9
00030 FOR I=1 TO 10
00040 PRINT I
00050 NEXT I

produces the following output:

>RUN"PROGNAME"
1
2
>>ESCAPE CONDITION ENCOUNTERED<<
>>00050 NEXT I

This program stops executing at line 00050, when the first ESCAPE WHEN (I=3) condition is true. The message “ESCAPE CONDITION ENCOUNTERED” and the line that caused the ESCAPE are displayed in Thoroughbred Basic Console Mode. At this point, Thoroughbred Basic clears the ESCAPE WHEN conditions. When the second condition is met (I=9), no ESCAPE WHEN processing occurs.

ESCAPE directive

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF