Chapter 20: Extending ColdFusion Pages with CFML Scripting
do-while loop: do statement while (expr) ;
// Complete do-while loop on a single line
a = ArrayNew(1);
do {a[loop1] = loop1 + 5; loop1 = loop1 + 1;} while (loop1 LT 10);
// Multiline do-while loop
a = ArrayNew(1);
do
{
a[loop1] = loop1 + 5;
loop1 = loop1 + 1;
}
while (loop1 LT 10);
switch-case: switch (expr) {case const-expr : statement break ; default : statement }
In this syntax, const-expr must be a constant (i.e., not a variable, a function, or other
expression). Only one default statement is allowed. There can be multiple case
statements. You cannot mix Boolean and numeric case values in a switch statement.
No two constants may be the same inside a switch statement.
switch(name)
{
case "John":
{
}
case "Mary":
{
}
default:
{
}
} //end switch
for-in loop: for (variable in collection) statement ;
Note that variable can be any ColdFusion identifier, and collection must be the name
of an existing ColdFusion structure.
for (x in mystruct) mystruct[x]=0;
male=true;
found=true;
break;
male=false;
found=true;
break;
found=false;
break;
341
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?