Home
 Introduction
 Using Holon
 Holon Tools
 Contact


 HolonJ

 HolonJForth
    Classes
    Methods
    Parameter
    Variables
    Forth
    FlowControl
    Compiler
    Libraries
    Constructors
    Exceptions 

 UsingHolonJ

Flow control

HolonJ offers the usual Forth flow control structures.

Counted loops

do

m n do ... i ... loop

This is equivalent to  for( int i = n; i<m; i++)  in Java.

The word i is the index of the loop. 

J

p q do ... 
      m n do ... i ... j ... loop  ... 
loop

The word j is the index of the outer loop.

times

m times ... loop

Same as m 0 do .. loop.  I use times in loops, where the index is not needed.

leave

m n do ... if ... leave then ... loop

m n do .. if ... else ... leave then ... loop

Execution continues behind loop.

return

m n do ... if ... return then ... loop

Exits the word, control is returned to the calling word.

Uncounted loops

again

begin ... again

Repeats the loop indefinitely.

begin ...  if ... return then ... again

Typical use. Returns control to the calling word.

while

begin ... ( flag -- ) while ... repeats

Repeats the loop as long as the flag is true. 

until

begin ... ( flag -- ) until

Repeats the loop as long as the flag is false.

Conditions

( flag -- )  if ... then

( flag -- )  if ... else ... then

Continues execution after if, if the flag is true. Otherwise jumps to else.

next

 

 

© 1999-2005 Wolf Wejgaard