While

DESCRIPTION

While is a generic loop controller module that performs the same function as the following C for control structure:
while( Condition In ) {
}

When While receives data from upstream or from a widget change, it begins a loop iteration. Input data is taken from the "initial" inputs, and while "Condition In" is true (cxParamLongGet returns non-zero), the input data is output on the "loop" outputs. When data returns from the loop, While takes input from the "loop" inputs and reevaluates "Condition In". When "Condition In" becomes false, the input data is output on the "final" outputs.

While acts as a data switcher, cycling data values through the loop while the iteration condition is true, and switching data values out of the loop when the iteration condition becomes false. Since the input data is not operated on, the ports are defined as type cxGeneric, allowing data of any type ports to be connected to it.

The While module provided defines 4 loop variables. For example, "Initial Value 0" and "LoopIn Value 0" are the initial and loop inputs, and "LoopOut Value 0", and "Final Value 0" are the loop and final outputs for a single loop variable.

It is possible to customize the While module to accept more loop variables or to accept particular types. Copy ${EXPLORERHOME}/modules/While.mres (UNIX) or %EXPLORERHOME%\modules\While.mres to a local directory, rename it myWhile.mres and run mbuilder(1E) on myWhile. Under the Build/Options menu, set the alternate executable to be ${EXPLORERHOME}/modules/While (UNIX) or %EXPLORERHOME%\modules\While.

The correspondence between input ports and output ports and a loop variable is defined by the name. Initial input ports begin with the string "Initial", looping input ports begin with "LoopIn", looping outputs begin with "LoopOut", and final outputs begin with "Final". The module looks for input and output ports whose names begin with these key words are the same after the key word. It must find at least one input port and at least one output port with the same suffix to create a match for a loop variable. That is, defining an initial input with no corresponding loop input is permitted.

You may define any number of loop variables in this way, using more descriptive port names. You may also change the port types of the loop variables to ensure that your new module is used correctly.

INPUTS

Port: Condition In
Type: Parameter
The loop condition. The module loops until Condition In becomes zero.

Port: Initial Value 0
Type: Generic
Optional: This port is optional.

Port: Initial Value 1
Type: Generic
Optional: This port is optional.

Port: Initial Value 2
Type: Generic
Optional: This port is optional.

Port: Initial Value 3
Type: Generic
Optional: This port is optional.
Initial values.

Port: LoopIn Value 0
Type: Generic
Optional: This port is optional.

Port: LoopIn Value 1
Type: Generic
Optional: This port is optional.

Port: LoopIn Value 2
Type: Generic
Optional: This port is optional.

Port: LoopIn Value 3
Type: Generic
Optional: This port is optional.
Loop return values.

WIDGETS

OUTPUTS

Port: Condition Out
Type: Parameter
The loop condition passed through from the input Condition In.

Port: Final Value 0
Type: Generic

Port: Final Value 1
Type: Generic

Port: Final Value 2
Type: Generic

Port: Final Value 3
Type: Generic
Final outputs of the loop.

Port: LoopOut Value 0
Type: Generic

Port: LoopOut Value 1
Type: Generic

Port: LoopOut Value 2
Type: Generic

Port: LoopOut Value 3
Type: Generic
Looping outputs.

KNOWN PROBLEMS

SEE ALSO

For, Repeat.
[Documentation Home]
© The Numerical Algorithms Group Ltd, Oxford UK. 2000