For |
Top Previous Next |
DescriptionThe For statement contains a block of commands that are executed as a property is increased or decreased until it reaches a terminating condition. The initial and final values of the property are specified, as well as the incremental step value. The For statement always concludes with an End statement. For more information, see the Flow Control Script Reference.
Syntax
Details•All commands between For and End are executed for each increment or decrement of the property. •The "step" keyword is used with the For command to specify the increment size; this can be positive, negative, or omitted entirely for the loop to assume an increment of +1. If the iterator is a TimeSpan value, the assumed increment is +1 day. •The fourth example shown above will increment mySpacecraft.A by myVariable, beginning at 7000 and ending at 8000. •To create complex logic flow, you can construct nested loops using multiple For commands, along with If and While statements. •The Break and Continue statements can be used to control logic flow for exiting For loops. •In nanosecond timing precision mode, properties and methods with a state are not reset at the start of each iteration of a For loop. oThe "with reset" keywords can be used to force these properties and methods to reset their state at the start of each iteration of a For loop as shown in the fifth example above. •In millisecond timing precision mode, properties and methods with a state are automatically reset at the start of each iteration of a For loop. oThe "without reset" keywords can be used to prevent the state from being reset.
Command EditorValue to Change
Initial Value
Finished Value
Increment
Script
Description
See Also•If •Flow Control Script Reference •Properties and Methods with a State
|