Continue expressions

A continue expression causes the next iteration of the innermost enclosing while, for, or foreach loop.

The value of the continue expression is always the value zero (0).

Expression

Syntax

Returns

Continue

continue

When used in a while expression, control is passed to the while condition. When used in a for expression, control is passed to the step expression.

The object of the following example is to populate the drop-down list with values from the XML file. If the value of the current XML element is “Display data for 3,” then the while loop exits via the break expression. If the value of the current XML element is “Display data for 2”, then the script adds 2 to the variable i (which is the counter) and immediately the loop moves on to its next cycle. The last two lines are ignored when the value of the current XML element is “Display data for 2”.

    var List = ref(xfa.record.lists.list1) 
    var i = 0 
    while (List.nodes.item(i+1).value ne "5") do 
    if (List.nodes.item(i) eq "Display data for 3") then 
    break 
    endif 
    if (List.nodes.item(i) eq "Display data for 2" then 
    i=i+2 
    continue 
    endif 
    $.addItem(List.nodes.item(i).value,List.nodes.item(i+1).value) 
    i=i+2 
    endwhile

// Ethnio survey code removed