ForEach Loop Edit Tab
- Updated2025-07-21
- 2 minute(s) read
ForEach Loop Edit Tab
Use the ForEach Loop edit tab in the TestStand Sequence Editor to configure the ForEach step.
The ForEach Loop edit tab contains the following options:
- Array/InputRecordStream to Interate Over —The expression that determines the array or InputRecordStream over which the loop iterates. The steps within the block execute once for each element in the array or stream. Choose whether to iterate over an array or a stream by selecting the appropriate option from the Iterate Over Array / Iterate Over Stream dropdown.
-
Loop Variables (Optional)
—
Expressions
that determine the location to store information about the current loop interation.
-
Current Element
—An expression that determines the variable or property in which to reference the current element in the array or to store the next record from the InputRecordStream during each iteration of the loop.
- Interating Over Arrays —The location the expression specifies must be of the same type as the element type for the Array to Iterate Over option. Typically, you specify a local variable so the steps in the block can read or modify the current array element by referring to the local variable. The current element reference is valid only while the loop executes, and the reference resets after the loop completes. If the loop prematurely exits, the current element references the array element of the exiting iteration.
- Interating Over Streams — Current Element must refer to a container or array. Each iteration of the loop updates the value of the Current Element.
- Current Offset —An expression that determines the numeric variable or property into which to store current offset during each iteration of the loop. For zero-based one-dimensional arrays, the offset is equal to the index of the array. For multi-dimensional arrays, the offset is the linearized index of the array. For streams, the offset is a zero-based counter of the number of loop iterations.
- Current Subscript —An expression that determines the string variable or property into which to store the subscript of the current element in the Array to Iterate Over option. Examples of the subscripts include [23] and [1][3]. Current Subscript is disabled when Iterate Over Stream is selected.
-
Current Element
—An expression that determines the variable or property in which to reference the current element in the array or to store the next record from the InputRecordStream during each iteration of the loop.
- Interate Over Array/Interate Over Stream —Specifies if this For Each loop iterates over an array or an InputRecordStream.
-
Stream Options
—Settings that specify options specific to iterating over streams. These settings are hidden if
Iterate Over Array
is selected.
- Field Mapping (Optional) —Specifies which container subproperties or array elements of the Current Element to store fields from the InputRecordStream to.
-
Auto Close at End of File
—Check this box to automatically clean up the InputRecordstream being read at the end of the loop. When this box is checked, upon terminating the loop, the For Each step closes the stream and sets the object reference in the
InputRecordStream to Iterate Over
expression to Nothing.
Note Automatic cleanup only occurs if the loop terminates normally by encountering end of file (EOF). Cleanup does not occur if execution flow exits the loop for some other reason, for example via a Goto step.