
Chapter 11 Flow Control Statements
11-15
REPEAT-UNTIL (Statement)
Function
Executes a tail decision iteration.
Format
REPEAT
:
UNTIL [<Conditional expression>]
Explanation
This statement repeats statements between a REPEAT statement and an
UNTIL statement until <Conditional expression> is satisfied.
If <Conditional expression> is ignored, it is regarded as true (except for 0) and
a loop is executed only once.
There is also a DO-LOOP UNTIL statement which serves the same function as
REPEAT-UNTIL, but only DO-LOOP UNTIL should be used.
Related Terms
DO-LOOP, WHILE-WEND
Example
DEFINT li1, li2, li3, li4, li5, li6, li7, li8, li9
DO WHILE li1 > li2 'Executes a head decision iteration.
IFli1=4THENEXITDO 'ExitsfromDO-LOOPifli1=4.
FORli3=0TO5 'RepeatsaprocessofFOR-NEXT5times.
FOR li4 = li5 TO li6 'Repeats the process of FOR-NEXT by adding 1 to the
value
'of li5 every time the repetition is done until li5
becomes
'the value of li6.
FORli7=1TOli8STEP2 'RepeatstheprocessofFOR-NEXTbyadding2tothe
'value every time the repetition is done from 1 until
'it becomes li8.
IFli2=2THENEXITFOR 'ExitsfromFOR-NEXTifli2<0.
WHILE li2 < li9 'Executes a head decision iteration.
GOSUB *samp2
li9=li9+1
WEND 'Calls a GOSUB *samp2 statement until li2 < li9.
NEXT li7 'Repeats.
NEXT 'Repeats.
NEXT 'Repeats.
li9=0
REPEAT 'Executes the tail decision iteration.
GOSUB *samp2
li9=li9+1
UNTIL li9 < 5 'Calls a GOSUB *samp2 statement until li9 < 5.
LOOP 'Repeats.
Komentarze do niniejszej Instrukcji