LOOP is a CAOS command controlling flow.


LOOP marks the start of a block of code which is to be looped unboundedly. There are two types of unbounded loop in CAOS: LOOP..EVER and LOOP..UNTL.


Syntax: LOOP .. EVER

LOOP..EVER just repeats the same block of code over and over, until a STOP instruction is reached, or the script is interrupted (if running SLOW).


Syntax: LOOP .. UNTL cond (condition)

LOOP..UNTL repeats the loop block, but at the end of each iteration cond is evaluated and if it is found to be true, the loop is terminated. STOP and interruptions still break out of the loop, as above.

This is a do { ... } until (cond) loop in many programming languages. To simulate a while loop, you can wrap the whole thing in a DOIF.

Warning sign
Do not attempt to break out of any loop using a GOTO or RETN command! It will crash your script. STOP is the only valid instruction for breaking a loop.


This uses LOOP..UNTL to almost-replicate an ENUM loop, outputting UNIDs as it goes:

SETA va00 NCLS NULL 0 0 0
TARG va00
  OUTS "\n"
UNTL TARG eq va00

LOOP..EVER can be used, and is in the Bootstrap, to continue doing something until a script interrupts.

See also

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.