Foreach expressions

A foreach expression iterates over the expression list for each value in its argument list.

The value of the foreach expression is the value of the last expression list that was evaluated, or zero (0), if the loop was never entered.

The in condition, which is executed only once (after the loop variable has been declared) controls the iteration of the loop. Before each iteration, the loop variable is assigned successive values from the argument list. The argument list cannot be empty.

Expression

Syntax

Returns

Foreach

foreach variable in( argument list )do 
    expression list 
endfor 
Use a comma (,) to separate more than one simple expression in the argument list. 

The value of the last expression list that was evaluated, or zero(0), if the loop was never entered.

In the following example, only the values of the “display” XML elements are added to the foreach drop-down list.

    foreach Item in (xfa.record.lists.list1.display[*]) do 
    $.addItem(Item,"") 
    endfor

// Ethnio survey code removed