REPEAT (REP.)
A statement which is the starting point of a REPEAT…UNTIL loop. A single REPEAT may have more than one UNTIL, but this is bad practice.
The purpose of a REPEAT…UNTIL loop is to make BBC BASIC(Z80) repeat a set number of instructions until some condition is satisfied.
REPEAT UNTIL GET=13 :REM wait for CRX=0
REPEAT
X=X+10
PRINT "What do you think of it so far?"
UNTIL X>45You must not exit a REPEAT…UNTIL loop with a GOTO. If you jump out of a loop with a GOTO (How could you!!!) you should jump back in. If you must jump out of the loop, you should use UNTIL TRUE to ‘pop’ the stack. For (a ghastly) example:
10 i=1
20 REPEAT: REM Print 1 to 100 unless
30 I=I+1: REM interrupted by the
40 PRINT i: REM space bar being pressed
50 x=INKEY(0): REM Get a key
60 IF x=32 THEN 110:REM exit if <SPACE>
70 UNTIL i=100
80 PRINT "****"
90 END
100 :
110 UNTIL TRUE: REM Pop the stack
120 PRINT "Forced exit":REM Carry on with program
130 FOR j=1000 TO 1005
140 PRINT j
150 NEXTSee the keyword UNTIL for ways of using REPEAT…UNTIL loops to replace unconditional GOTOs for program looping.
See the sub-section on ‘Program Flow Control’ in the ‘General Information’ section for more details on the working of the program stack.
Syntax
REPEAT
Associated Keywords
UNTIL