Skip to content

Actions ForIn

thica edited this page Jan 10, 2020 · 6 revisions

ForIn

Loops through an array of custom vars

Attribute Description
string forin
varname Variable name to loop through (without brackets)
level the bracket level to use (from left), 1 = leftmost
actionname multi line action / macro name to call for each var
breakvar Break Var to exit the loop, set to 1 to exit the forin loop
A short example:
<action name="loop through vars" string="forin" varname="myarray[]"  level="1" actionname="fkt dosomething"/>

Given, you have the following var array

myarray[1] = "Apple" myarray[2] = "Orange" myarray[3] = "Cherry"

This will create the following pars for the first iteration

Varname: $par(forin_value) = "Apple" $par(forin_var) = "myarray[1]" $par(forin_varcore) = "myarray" $par(forin_index) = "1"

<action name="loop through vars" string="forin" varname="myarray[1]_subelement[]" dstvarname="elementname" level="2" actionname="fkt dosomething"/>

Given, you have the following var array

myarray[1]_sublement[1] = "Green Apple" myarray[1]_sublement[2] = "Red Apple" myarray[1]_sublement[3] = "Yellow Apple" myarray[2]_sublement[1] = "Green Orange" myarray[2]_sublement[2] = "Orange Orange" myarray[3]_sublement[1] = "Small Cherry"

This will create the following subvars for the second iteration. Note, it will iterate only through the Apples, not through the oranges

Varname: $par(forin_value) = "Red Apple" $par(forin_var) = "myarray[1]_sublement[2]" $par(forin_varcore) = "myarray[1]_sublement" $par(forin_index) = "2"

Clone this wiki locally