FOR


Next: HCos Up: COD Command Summary Previous: EXP

FOR

Set up a FOR...LOOP or a FOR...+LOOP structure using the top two numbers in the stack to denote the range. The index for the FOR loop is an INTEGER*2, hence the maximum value is 32767. This word can only be used in colon definitions.

Example:

COD> : TMP 4 1 FOR I . LOOP ;

COD> TMP
 1.0
 2.0
 3.0
 4.0
Warning to people who know Forth: The COD FOR statement is similar to the Forth DO statement; however, there is an important difference concerning the two numbers that precede the FOR. In COD, these represent the upper and lower index values respectfully; in Forth, the first number is one greater than the upper index value.



Web Page Maintained by: Dr. Lawrence E. Brown elwin@redshift.gsfc.nasa.gov