Home
Main Introduction Features Constants Statements Database Objects Parser Serial-Communication Samples Misc
Statements>Loop Statements
Caravan Business Server>Help>Statements>Loop Statements
Syntax <CARAVAN>

loop counter variable (end value of the counter)
...Any number of HTML/Caravan statements can be included
......
break
...

repeat counter variable ( end value of the counter)
</CARAVAN>
Text Loop statements allow you to execute one or more lines of code repetitively. When we know that we must execute a statement a specific number of times then we use the loop statement. The loop statement uses a counter variable that increases in value during each repetition of the loop.
Sample Example -1 Break
<HTML>
<BODY>
<CARAVAN>loop ctr (100)
"The value of the counter is "
ctr(counter)
"<br>"
if ctr(counter) = "50"
break
repeat ctr 101
</CARAVAN>
</BODY>
</HTML>

Loop statements in Caravan can be nested to any number of levels .

End value of the loop statement can be replaced with a variable. But the end value of a repeat statement has to be a constant. Loops can be used to display array values and record sets directly.
Example - 2 Counter
<HTML>
<BODY>
<CARAVAN>
vartemp
temp(delim)=","
temp(name)="John,Mary,Chris"
loop ctr (temp(name(00)))
ctr(counter);") ";temp(name(ctr(count)));"<br>"
repeat ctr 100
</CARAVAN>
</BODY>
</HTML>
Example -3 Count
<HTML>
<BODY>
<CARAVAN>
var temp
temp(delim)=","
temp(name)="John,Mary,Chris"
loop ctr (temp(name(00)))
ctr(counter);") ";temp(name(ctr(count)));"<br>"
repeat ctr 100
</CARAVAN>
</BODY>
</HTML>
Properties Count
Counter
Break
Back