WHILE


Next: X Up: COD Command Summary Previous: VAR

WHILE

The WHILE statement pops one number off the stack. If that number is true (not equal to 0.0), the statement following the WHILE will be executed. If the number is false, then control passes to the first statement following the REPEAT statement. This statement can only be used inside a BEGIN...WHILE...REPEAT loop in a colon definition.

Example:

COD> VAR Y                  ! Create variable Y

COD> : TEST 2 Y STO         ! Initialize Y to 2
COD> BEGIN
COD>   Y RCL .              ! Print the value of Y
COD>   Y RCL 1.E10 < WHILE  ! Recall number and test for <1.E10
COD>   Y RCL DUP * Y STO    ! Square and store new value
COD> REPEAT ;

COD> TEST
 2.0
 4.0
 16.O
 256.0
 4.2949673E+9
 1.8446744E+19



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