Skip to main content

CSP Tags: <csp:while>

The <csp:while> tag repeats a code block while evaluation of its controlling condition yields true.

Add the code shown below to MySamplePage.CSP between <body> and </body>. The loop executes OddEvenTest ten times sending the numbers 1-10 to OddEvenTest. You can remove all other code from between <body> and </body>.

<body>
<script language="Cache" runat="Server">
Set i=0
</script>
<ul>
<csp:while condition="i<10" counter="j">
<li>#(..OddEvenTest(j))#</li>
<script language="Cache" runat="Server">
Set i=i+1
</script>
</csp:while>
</ul>

<script language="cache" method="OddEvenTest" arguments="val1:%Integer"
returntype="%String">
  If (val1#2=0) { quit "even" }
  Else {quit "odd"}
</script>
</body>

Click View —> Web Page to view MySamplePage.CSP in a Web browser.

generated description: whileloop20142

FeedbackOpens in a new tab