Statement BEGIN SEQUENCE Foundation
Introduces control structure for BREAK or Break(). The BEGIN SEQUENCE statement introduces a control structure for handling runtime errors.
BEGIN SEQUENCE
<SourceCode>...
[BREAK [<Expression>]]
<SourceCode>...
[RECOVER [USING <VarName>]]
<SourceCode>...
END [SEQUENCE]
The statements BEGIN SEQUENCE and ENDSEQUENCE form a control structure which is used mainly for handling runtime errors. The execution of code between the two statements can be interrupted by a BREAK statement or the Break() function, and the program continues at the next executable line which follows the ENDSEQUENCE statement or the RECOVER statement. When no BREAK is executed within the BEGIN SEQUENCE...END structure, a program continues after the ENDSEQUENCE statement and ignores the RECOVER statement. RECOVER marks a continuation point to which control passes only in the case of a BREAK statement or the Break() function.
The RECOVER statement is used exclusively for the treatment of runtime errors. With the USING option, a value specified with BREAK <Expression>, which is usually an error object, can be assigned to the variable <VarName>. An error object contains information about a runtime error and can be evaluated in the source code following the RECOVER statement.
BEGIN SEQUENCE..RECOVER blocks have the following restrictions: The statements EXIT, LOOP and RETURN cannot be used between BEGIN SEQUENCE and RECOVER, but can be used in the code following the RECOVER statement. That means that program execution between the statements BEGIN SEQUENCE and RECOVER can be interrupted only by the BREAK statement or by the Break() function.
BEGIN SEQUENCE..RECOVER..END is a very powerful control structure for the handling of runtime errors. The statements may be optionally nested to any depth. The BREAK statement can be used for localized error handling specific to the context of the BEGIN SEQUENCE..END code. A special continuation point can be defined with ENDSEQUENCE, at which point a program continues as soon as the BREAK statement is executed. Deeply nested DO WHILE loops, for example, can be exited by a single BREAK statement.
Further information about the treatment of runtime errors can be found in the descriptions of the error object class and the ErrorBlock() function.
Notes for multiple threads The BREAK statement interrupts the program flow of the thread that executes the statement. Therefore BREAK can be issued outside a BEGIN SEQUENCE..END structure when using multiple threads. In this case BREAK terminates the thread when called outside BEGIN SEQUENCE..END. If it is the very first thread, the program ends.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.