Form a loop with a test at the beginning that allows a subordinate statement block to execute repeatedly, either until or
while a single or compound condition is satisfied. The UNTIL statement block executes until the condition is true. The WHILE
statement block executes while the condition is true.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.
Syntax: for Format 1
REPEAT
.
.
UNTIL|WHILE condition1 [AND|OR condition2
... [... AND|OR conditionN]]
statementblock
Syntax: for Format 2
REPEAT
statementblock1
UNTIL condition
statementblock2
Syntax: for Format 2
REPEAT
statementblock1
UNTIL condition
statementblock2
statementblock3
General Rules:
- Use these statements with REPEAT to test a condition at the middle or end of a loop.
- In the Format 2, AMB tests the condition after the REPEAT
statementblock1 executes. Be careful using this format for reading records--it can read the last record twice.
- In the Format 3, AMB tests the condition after the REPEAT
statementblock1 executes, but before the UNTIL
statementblock2 executes. When the UNTIL condition is true, the UNTIL
statemenblock2 does not execute.
Examples:
Find the first X in a string of characters.
PARA FIND-X
A-SUB = 1
UNTIL A-SUB > 100
... OR CHAR (A-SUB) = "X"
A-SUB = A-SUB + 1
IF A-SUB <= 100
CHARACTER-COUNT = A-SUB
ELSE
.
.
.
Use WHILE to achieve the same results.
WHILE A-SUB <= 100
... AND CHAR (A-SUB) NOT = 'X'