Do: Difference between revisions
Gordon.dye (talk | contribs) |
Gordon.dye (talk | contribs) No edit summary |
||
Line 17: | Line 17: | ||
CONFIG STYLE INDENT will cause lines between the DO and LOOP statements to be indented. | CONFIG STYLE INDENT will cause lines between the DO and LOOP statements to be indented. | ||
===Note=== | |||
I you need to execute a group of stements once irrespective of the loop terminating condition, don't specify a condition on the DO statement and instead place it on the LOOP statement. | |||
===Example=== | ===Example=== |
Latest revision as of 11:29, 6 October 2024
The DO/LOOP structure, which 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
DO [{WHILE|UNTIL} <conditional expression>]
Defaults
- When no WHILE or UNTIL condition is specified, execute.
- Loop until the corresponding LOOP statement's conditions are met, or an EXIT DO statement is encountered.
Parameters
The WHILE keyword indicates that the loop should be executed 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 the loop should be executed 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.
CONFIG STYLE INDENT will cause lines between the DO and LOOP statements to be indented.
Note
I you need to execute a group of stements once irrespective of the loop terminating condition, don't specify a condition on the DO statement and instead place it on the LOOP statement.
Example
This do loop waits for Check Boxes to be selected before the operator pushes a "Done" Button. (The button sets the Fkey to 99, thereby exiting the loop.
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