The for statement repeatedly executes the same block of statements
as long as a stated test condition, based upon a counting mechanism, remains
A counting variable is created that allows the for loop to execute
(iterate) a specified number of times. As long as the test condition remains
true, for each iteration of the counter, the block of statements
is executed. The first time that the test condition returns false,
the for loop is terminated, the block of statements is not executed,
and the program jumps to the first line of code (if any) after the for
The test condition is defined using three optional expressions.
Note that the for loop does not have to finish all of the prescribed
iterations. For example, you can leave a for loop by executing
a break statement or calling the Lang.exit function.
- The first expression sets the starting value for a counting variable.
You can use the var statement to create the counting variable
inside this expression.
- The second expression defines the ending value for the counting
variable. For each iteration, a boolean true or false
test is performed on the expression. As long as true is returned,
the for loop continues to iterate. When false is returned,
the for loop is immediately terminated.
- The third expression is used to increment or decrement the counting
The block of statements executed by the for loop can be any legal
WMLS code (including more for statements).
Code for ForExample.wml
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
for loop is over
Code for ForExample.wmls
extern function findfor()
var end = 95;
for(var count=0; count
< end; count++;)
// You can place any code you desire
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.