Propeller Manual

Table Of Contents
QUIT – Spin Language Reference
Page 186 · Propeller Manual v1.1
QUIT
Command: Exit from REPEAT loop immediately. T
((PUB PRI))
QUIT
Explanation
QUIT is one of two commands (NEXT and QUIT) that affect T REPEAT loops. QUIT causes a REPEATT
loop to terminate immediately.
Using QUIT
QUIT is typically used as an exception case, in a conditional statement, in REPEAT loops to
terminate the loop prematurely. For example, assume that
DoMore and SystemOkay are
methods created elsewhere that each return Boolean values:
repeat while DoMore 'Repeat while more to do
!outa[0] 'Toggle status light
<do something> 'Perform some task
if !SystemOkay
quit 'If system failure, exit
<more code here> 'Perform other tasks
The above code toggles a status light on P0 and performs other tasks while the DoMore method
returns
TRUE. However, if the SystemOkay method returns FALSE partway through the loop, the
IF statement executes the QUIT command which causes the loop to terminate immediately.
The
QUIT command can only be used within a REPEAT loop; an error will occur otherwise.