else  ( -- )

published: 8 January 2022 / updated 16 February 2022

Lire cette page en français

 

vocabulary: forth

Word of immediate execution and used in compilation only. Mark a alternative in a control structure of the type IF ... ELSE ... THEN

At runtime, if the condition on the stack before IF is false, there is a break in sequence with a jump following ELSE, then resumed in sequence after THEN.

Example:

: TEST ( ---) 
    CR ." Press a key " KEY 
    DUP 65 122 BETWEEN 
    IF 
        CR 3 SPACES ." is a letter " 
    ELSE 
        DUP 48 57 BETWEEN 
        IF 
            CR 3 SPACES ." is a digit " 
        ELSE 
            CR 3 SPACES ." is a special character " 
        THEN 
    THEN 
    DROP ; 

Legal: site web personnel sans commerce / personal site without seling