The BREAK statement immediately transfers control to the first
statement past the end of the FOR, WHILE, or REPEAT statement
that contains the BREAK statement. The BREAK statement appears
as a single word: BREAK is equivalent to a GOTO to a label
placed just past the end of the closest FOR, WHILE, or REPEAT
statement.
Use caution when using the BREAK statement because future
additions to the code may result in the BREAK statement leaving
a different loop than was originally intended.
The following example shows the usage of the BREAK statement.
name := GetInput('Your name?');
IF ExitKeyPressed THEN BREAK;
address := GetInput('Your address?');
IF ExitKeyPressed THEN BREAK;
Person[Num].Name := name;
Person[Num].Addr := address;
Num := SUCC(Num);
UNTIL Num > 50;
In the example, a user-defined function GetInput interacts with
the user and sets a global Boolean variable ExitKeyPressed if
the user presses an Exit key. The BREAK statement exits the
loop here, without storing data in the array.