<cfwhile>

Simplification of the tag cfloop-condition, analog to the cfscript "while" loop.

This tag must have a body.

This tag is also supported within <cfscript>

Attribute Description
condition
boolean, optional

condition o the expression

label
string, optional

used to address this loop from a "break" or "continue" statement (instead of the nearest one).

<cfwhile
    [condition=boolean]
    [label=string]
><!--- body ---></cfwhile>

Examples

testCondition = true;
cnt = 0;
while(testCondition) {
    cnt = cnt + 1;
    if (cnt EQ 5) {
        testCondition = false;
    }
}
echo(cnt);
// breaking out using a label
x = 0;
WhileLabel: while (x < 10){    
    writeOutput("x is #x#<br>");
    switch (x){
        case 1:
            break;
        case 3:
            break WhileLabel;
    }
    x++;
    writeOutput("end of of loop<br>");
}
writeOutput("After loop, x is #x#<br>");

See also