While expressions

A while expression is an iterative statement or loop that evaluates a given simple expression. If the result of the evaluation is true (1), FormCalc repeatedly examines the do condition and returns the results of the expression lists. If the result is false (0), then control passes to the next statement.

A while expression is particularly well-suited to situations in which conditional repetition is needed. Conversely, situations in which unconditional repetition is needed are often best dealt with using a for expression.

Expression

Syntax

Returns

While

while ( simple expression ) do expression list endwhile

The result of the list of expressions associated with the do condition.

In the following example, the values of the elements are added to a drop-down list from an XML file using the addItem method for all of the XML elements listed under list1 that are not equal to 3:

    var List = ref(xfa.record.lists.list1) 
    var i = 0 
    while ( List.nodes.item(i+1).value ne "3")do 
    $.addItem (List.nodes.item(i).value,List.nodes.item(i+1).value) 
    i = i + 2 
    endwhile

// Ethnio survey code removed