For Each...End For Each
Kalipso - Form - Actions - Actions Description - Group Code - For Each...End For Each
For each is an action for traversing items in a collection. For each is usually used in place of a standard for statement Unlike other for loop constructs, however, for each loops usually maintain no explicit counter, they essentially say "do this to everything in this set", rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read. This action have the following options: Browse a Table Control, Browse the result of a Stored Procedure, Browse a Result of a Select Statement, Browse a SQL Advanced, Browse the tokens of a String, Browse the Childs of a XML, For and Browse a JSON Array.
Action available for the following operating systems:
Parameters
When you use this action, a window opens that asks you to select the object you want to browse. Choosing the desired option click next.
Browse a Table Control:
Table Control <unquoted string> - The name of the table control that the user wants to browse.
Target <unquoted string> - The control or variable that saves the value of each for iteration.
Browse the result of a Stored Procedure:
The parameters of that option are the same of Exec. Procedure action.
Browse a Result of a Select Statement:
The parameters of that option are the same of Select action.
Browse a SQL Advanced:
The parameters of that option are the same of SQL Advanced action.
Browse the tokens of a String:
Source String <string> - This parameter is the string that the user wants to browse.
String Separator <string> - This parameter is the string separator for the source string.
Target For Each Token <string> - The control or variable to save each token.
Browse the Childs of a XML:
Source XML <string> - The complete path and name of the source XML file.
Child's Name <string> - The name of the XML child that the user wants to browse.
Ignore Name´s Prefix <combobox> - This parameter indicates that if the user wants or not to ignore the prefix of each name. This parameter have three possible values: Yes, No, dynamic.
Content's Target <string> or <numeric> - The control or variable that saves the result of each iteration.
Attribute <string> - The name of the XML attribute.
Target <string> or <numeric> - The control or variable that saves the XML attribute.
For:
Type <string> or <numeric> - The type of the step and initial value of the for action.
Enumerator <string> or <numeric> - Object used to control the iteration.
Initial Value <string> or <numeric> - Expression used to initialize the enumerator.
While <unquoted string> - Condition to continue the loop.
Step <unquoted string> - Expression to set the value of Enumerator in each iteration.
Browse a JSON Array:
Source JSON <string> - Enter the JSON source with the array to iterate on.
Target of Value - Pick a Variable or Control that will receive each item of the array.
Target of Type - Define the target variable that will receive the type of item inside the array while it is being iterated. It can be one of:
String
Numeric
Object
Array
Boolean
Null
Usage
Consider the following information:
Code | Name | Stock |
1 | Coca Cola | 100 |
2 | Pepsi | 200 |
3 | Pork Shops | 300 |
Example 1
Browse a Table Control:
Result:
Iteration | Variable | Value |
1 | VAR(0) | 1 |
2 | VAR(0) | 2 |
3 | VAR(0) | 3 |
Note that in each iteration, VAR(0) stores the value of line index of the table control.
Example 2
Browse the tokens of a String:
Result:
Iteration | Variable | Value |
1 | VAR(1) | "kalipso" |
2 | VAR(1) | "is" |
3 | VAR(1) | "a" |
4 | VAR(1) | "tool" |
5 | VAR(1) | "to" |
6 | VAR(1) | "develop" |
7 | VAR(1) | "mobile" |
8 | VAR(1) | "applications" |
Example 3
For:
Result:
Variable | Value |
VAR(0) | 6 |
VAR(1) | 5 |
Example 4
For:
Result:
Variable | Value |
VAR(0) | "aaaaaaaaaa" |
VAR(1) | 10 |
Last updated