CAOS-Programmierung: Beispiele: Schleifen

Beispiel einer einfachen Schleife und doif abfrage

* Erzeugt mit kaos-compiler-alpha.01
SETV VA00 99
LOOP
OUTS "\n"
DOIF VA00 EQ 1
OUTS "One bottle of beer on the wall,\n"
OUTS "One bottle of beer...\n"
OUTS "Take it down, pass it around,\n"
OUTS "No bottles of beer on the wall!\n"
ELSE
OUTV VA00
OUTS " bottles of beer on the wall,\n"
OUTV VA00
OUTS " bottles of beer...\n"
OUTS "Take it down, pass it around,\n"
DOIF VA00 GT 2
SETV VA01 VA00
SUBV VA01 1
OUTV VA01
OUTS " bottles of beer on the wall!\n"
ELSE
OUTS "One bottle of beer on the wall!\n"
ENDI
ENDI
SUBV VA00 1
UNTL VA00 EQ 0
OUTS "No more bottles of beer on the wall :(\n"
RSCR