$WBWHILE - loop while a condition is True
Important: If condition is not set properly
$WBWHILE function can get in infinite loop and stop the page processing until
servers CGITimeOut is reached.
Availability
$WBWHILE is available for use with all WBSP commands.
Syntax
$WBWHILE{condition|content}
$WBWHILE[condition|content]
Parameters
condition - an expression that can be True or false when evaluated
content - block of code (including
WhizBase elements) that will be repeated while
condition is True
Returns
Code contained in
content repeated while
condition is True.
Example
<!--
[FormFields]
wb_command=r
-->
<!--WB_BeginTemplate-->
<html>
<head>
<title>Titles</title>
</head>
<body>
$wbsetv[loopcounter|0]
$WBWHILE[$wbgetv[loopcounter]<=10|
The loopcounter value is:$wbgetv[loopcounter]<br>
$wbsetv[loopcounter|$wbcalc[$wbgetv[loopcounter]+1]]
]
Loop ended, loopcounter value is $wbgetv[loopcounter]!
</body>
</html>
After running this example, the resulting page in browser, may look like
this:
The loopcounter value is:0
The loopcounter value is:1
The loopcounter value is:2
The loopcounter value is:3
The loopcounter value is:4
The loopcounter value is:5
The loopcounter value is:6
The loopcounter value is:7
The loopcounter value is:8
The loopcounter value is:9
The loopcounter value is:10
Loop ended, loopcounter value is 11!