Skip to content

Commit

Permalink
Merge pull request #1468 from terrywhitney/patch-9
Browse files Browse the repository at this point in the history
Update _examples.md
  • Loading branch information
zspitzer authored Feb 28, 2025
2 parents 910113b + 3cd0c86 commit 6e79a92
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion docs/03.reference/02.tags/while/_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ while(testCondition) {
echo(cnt);
```

```luceescript+trycf
<!--- testing condition --->
<cfset testCondition = true>
<cfset cnt = 0>
<cfloop condition="#testCondition#">
<cfset cnt = cnt + 1>
<cfif cnt EQ 5>
<cfset testCondition = false>
</cfif>
</cfloop>
<cfoutput>#cnt#</cfoutput>
```

```luceescript+trycf
// breaking out using a label
x = 0;
Expand All @@ -25,4 +38,23 @@ WhileLabel: while (x < 10){
writeOutput("end of loop<br>");
}
writeOutput("After loop, x is #x#<br>");
```
```

```luceescript+trycf
<!--- breaking out using a label --->
<cfset x = 0>
<cfloop condition="x LT 10" index="i" label="WhileLabel">
<cfoutput>x is #x#<br></cfoutput>
<cfswitch expression="#x#">
<cfcase value="1">
<cfbreak>
</cfcase>
<cfcase value="3">
<cfbreak loop="WhileLabel">
</cfcase>
</cfswitch>
<cfset x = x + 1>
<cfoutput>end of loop<br></cfoutput>
</cfloop>
<cfoutput>After loop, x is #x#<br></cfoutput>
```

0 comments on commit 6e79a92

Please sign in to comment.