START

Member Of Menu: 
Branch
Argument Types: 
Real
Result Type(s): 
None
Invertible: 
No
Valid In Expression: 
No
Stack Diagram: 
Real1 Real2

The START operation is used to define a loop structure within a program. It is combined with the NEXT or STEP operation to define the boundaries of the loop.

The normal way START is used is one of the following:

≪ ... Real1 Real2 START ... operations ... NEXT ... ≫

or

≪ ... Real1 Real2 START ... operations ... Real3 STEP ... ≫

When START is executed, it pops two values of the stack which should be real values. Real1 is the starting value for the loop counter and Real2 is the ending value for the loop counter. When NEXT is executed, the loop counter is incremented by one. If the loop counter is less than or equal to the ending value, then execution jumps back to the operation following START and executes the body of the loop again. If the value is greater than the ending value after incrementing the loop counter, then execution continues after the NEXT operation, exiting the loop.

The STEP operation can be used in place of NEXT to specify an increment for the loop counter which is not one. When STEP is executed the top of the stack is popped. It expects to find a real value there. It adds that real value to the loop counter and then tests to see if the loop counter has reached the end. For a negative increment, the loop stops when the counter is less than the ending value. For a positive increment, the loop stops when the counter is greater than the ending value. If not yet at the end, it loops back to the operation following START. Otherwise, it exits the loop and execution continues after the STEP operation.

Note that in the body of the loop you do not have access to the loop counter. If you need access to the loop counter, you may want to use the FOR loop instead.

An error will be raised if this operation is used outside of program execution context.