Loop

From BR Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The Loop statement works in conjunction with Do and Exit Do.

DO/LOOP structure can be used to replace GOTO statements for more structured programming. Notably, labels or line numbers are not required to exit the loop.

The DO and LOOP statements must always be used in conjunction with one another to specify the beginning and ending of the loop. The Exit DO statement may be used to break out of the loop.

Syntax

LOOP [{WHILE|UNTIL} <conditional expression>]

Default

1.) When no WHILE or UNTIL condition is specified, continue executing the loop until the DO statement's conditions or an Exit DO indicate otherwise.

The WHILE keyword indicates that execution should return to the previous DO statement only if the specified conditional expression evaluates to true. If the conditional expression evaluates to false, execution will skip to the first line following the LOOP statement.

The UNTIL keyword indicates that execution should return to the previous DO statement only if the specified conditional expression evaluates to false. If the conditional expression evaluates to true, execution will skip to the first line following the LOOP statement.

The LOOP statement must be the last statement in a line, and the LOOP keyword is always required. CONFIG STYLE INDENT will cause lines between the DO and LOOP statements to be indented.

See the DO LOOP and Exit Do statements in this section for additional information about the DO/LOOP structure.

Examples

The following code uses a DO LOOP combination to allow a Check Box GUI to work:

00350     do
00360        input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3)
00370        print fields "24,1,N 2": Fkey
00380     loop While Fkey~=99

In this case, pressing ESC will set the Fkey equal to 99 and exit the loop.