Break expressions

A break expression causes an immediate exit from the innermost enclosing while, for, or foreach expression loop. Control passes to the expression following the terminated loop.

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

Expression

Syntax

Returns

Break

break

Passes control to the expression following the terminated loop.

In the following example, an if condition is placed in the while loop to check whether the current value is equal to “Display data for 2”. If true, the break executes and stops the loop from continuing.

    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 
    if (List.nodes.item(i) eq "Display data for 2" then 
    break 
    endif 
    endwhile

// Ethnio survey code removed