Lasso Soft Inc. > Home

[Iterate] ... [/Iterate]

The [Iterate] ... [/Iterate] tags loop through each element of a complex data type such as an array or a map. A variable is set to the value of each element of the complex data type in turn. This allows the same operation to be performed on each element.

The first parameter to the opening [Iterate] tag should be the complex data type which is to iterated through. The second parameter should be a reference to a variable that will be set to each item in turn. The second parameter is usually specified as (Variable: 'Variable Name').

The [Iterate] ... [/Iterate] tags can be used on any data type that supports the [...->Get] and [...->Size] parameters including maps, pairs, arrays, and strings. Custom data types are also supported providing they support the required member tags.

Note: The [Iterate] ... [/Iterate] tags can be used rather than performing a [Loop] ... [/Loop] on the size of an array and then [Array->Get] to fetch each particular item.

  • Syntax
  • Parameters
[Iterate: Array, (Variable: 'Item')]
  ... [Variable: 'Item'] ...
[/Iterate]

[Iterate: Map, (Variable: 'Item')]
  ... [Variable: 'Item'] ...
[/Iterate]

[Iterate: 'String', (Variable: 'Char')]
  ... [Variable: 'Char'] ...
[/Iterate]
Required Parameters
Complex Data Type The first parameter is a complex data type that is to be iterated through.
Variable Reference The second parameter is a reference to a variable which will be set to the value of each element of the complex data type in turn. Usually of the form (Variable: 'Variable Name')
Examples

To iterate through an array:

Use the [Iterate] ... [/Iterate] tags. In the following example each element of an array is output on a separate line. The opening [Iterate] tag contains the name of the variable that contains the array and a variable definition which will be set to each element of the array in turn.

[Variable: 'myArray' = (Array: 'Red', 'Blue', 'Green')]
[Iterate: $myArray, (Variable: 'temp')]
  <br>[Output: $temp]
[/Iterate]
Result:
<br>Red <br>Blue <br>Green
Tag Link [Iterate] ... [/Iterate] Category Conditional
Type Container Data Source Any
Support Preferred Version 6.0
Output Type None Security Tag
Implementation Internal Sets Lasso 6.0

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft