Parameters
Parameter |
Data Type |
Description |
---|---|---|
ItemId | String | ID ($idpart) of the list item |
ItemValue | String | Value ($valuepart) of the list item |
Index | String | Item number ($itemnr); optional |
SourceList | String | GOLD-separated list to be processed |
Return Values
None
Use
Allowed in all component types.
Description
The forlist/id
statement starts a loop that processes each item in an associative list of
id=value pairs. If the SourceList is an
indexed list (with no id=value pairs), the
ItemId and ItemValue will hold the same value. If the
Index is specified, it is also loaded.
The loop executes the code in the block until one of the following conditions is met:
- All items in the list have been processed
- Index
>
last item number - A break statement is encountered
After the loop completes (after the endfor statement), the Index has the value the last item number + 1, or the last item reached before a break statement was encountered.
The Index can be altered by the code in the loop, which enables you to conditionally make changes in the loop as it executes.
The following example processes a list of strings
until it finds "P"
in the id part.
variables string vList string vItemId string vItemValue string vIndex endvariables vList = "A=Athens;R=Rome;Sy=Syracuse;P=Pompey;Sp=Sparta" forlist/id vItemId, vItemValue, vIndex in vList if (vItemId = "P") putmess "Loop processing stopped on Item number: %%vIndex, Id: %%vItemId, Value: %%vItemValue" break endif putmess "Processing Item number: %%vIndex, Id: %%vItemId, Value: %%vItemValue" endfor
The resulting output looks like this:
Processing Item number: 1, Id: A, Value: Athens Processing Item number: 2, Id: R, Value: Rome Processing Item number: 3, Id: Sy, Value: Syracuse Loop processing stopped on Item number: 4, Id: P, Value: Pompey
Version | Change |
---|---|
9.5.01 | Introduced |