else  ( -- )

published: 28 January 2023 / updated 28 January 2023

Lire cette page en français

 

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

  (condition) 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 ." c'est une lettre " 
    else 
        dup 48 57 between 
        if 
            cr 3 spaces ." is a digit " 
        else 
            cr 3 spaces ." is a special character " 
        then 
    then 
    drop ;