\\ Noch ein paar Strukturen... 20dec92py 1. CASE wert_1 OF ausdruck_1 ENDOF wert_2 OF ausdruck_2 ENDOF ... wert_n OF ausdruck_n ENDOF defaultausdruck ENDCASE 2. Vorw„rts-Definitionen - wie im Target-Compiler oder mit einem Mehrpasscompiler. Funktioniert natrlich nur bei normalen W”rtern (nicht immediate und nur im Compile-Modus!) 3. Sequenzielles AND und OR flag1 ANDIF flag2 ANDIF .. ANDIF flag_n SO wennfall THEN flag1 ORIF flag2 ORIF .. ORIF flag_n SO wennfall THEN \ CASE OF ENDOF ENDCASE 10aug99py : CASE compile BEGIN ; immediate restrict : OF compile over compile = compile IF compile drop ; immediate restrict : ENDOF compile LEAVE compile THEN ; immediate restrict : ENDCASE compile drop ( ! ) compile DONE ; immediate restrict \ cr .( Be careful! Eaker drops with ENDCASE!) \ cr .( use BEGIN .. OF .. ENDOF .. DONE instead!) cr \\ : CASE-TEST ( n -- ) CASE 123 OF ." Dies war 123" ENDOF 0 OF ." Dies war eine Null, du Niete!" ENDOF 4 dup * OF ." 16 = 4 * 4 " ENDOF ." Sonst war nischt. " ENDCASE ; \ Predefinitions 20aug93py : makeghost state @ 0= IF defers notfound exit THEN last push lastcfa push dp push c@ 1+ negate >in +! >in @ compile Forward >in ! ; ' makeghost IS notfound Forward Ghost? ' Ghost? cfa@ | : ghost? ( cfa -- flag ) dup cfa@ [ swap ] Aliteral = IF >body @ 0<> ELSE drop false THEN ; : .unresolved ( -- ) voc-link list> 8 - list> dup cell+ name> ghost? IF dup cell+ .name THEN drop ; \ Sequential AND and OR 15dec91py : ANDIF compile IF 5 ; immediate restrict : ORIF compile 0= compile IF 6 ; immediate restrict : SO dup 5 = IF compile 0= THEN compile IF >r dup >r BEGIN dup r@ = WHILE compile THEN REPEAT r> r> swap 5 = IF compile ELSE THEN ; immediate restrict \\ Beispiel: : test1 dup 5 = ORIF dup 7 = SO ." 5 oder 7!" THEN drop ; : test2 dup 1 and 0= ANDIF dup 0> SO ." gerade und positiv" THEN drop ;