<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>


LEAVE Search:

In Flow Control Words in TurboForth Kernal

Word Name: LEAVE
Type: Standard word
Data Stack Signature: --
Return Stack Signature: ret_add max index --
Availability: V1.0  V1.1  V1.2
Description:

In a DO/LOOP or FOR/NEXT loop, causes the loop to exit. LEAVE should be used inside an IF...THEN block.

Example:

: TEST ( -- )
  10000 0 DO
    I .
    I 50 = IF ." EXITING EARLY" CR LEAVE THEN
  LOOP
;

In this example, the loop is supposed to execute 10,000 times. However, the loop exits when the index is equal to 50.

Comment:

none

See Also: DO  FOR  LOOP  NEXT 

<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>