developer sign in
where » create » reference » looping

looping


The script feature provides for both while and for looping. These take on the same syntax that a for or while does in java, C, or JavaScript.

Note: there is no break directive.


for loop

The for loop is used when you know in advance how many times the script should run.

Syntax
for (var=startvalue;var<=endvalue;var=var+increment) 
{
    code to be executed
}
Example
for (var i = 0; i < array.length; i++) {
  // do something
}
       
var i = 0;
for ( ; i < array.length; i++) {
  // do something
}

while loop

The while loop is used when you want the loop to execute and continue executing while the specified condition is true.

Syntax
while (condition is true)
{
    //code to be executed
}
Example
var foo = 0;
while (foo < 5) {
  // do something
  foo++;
}
var done = false;
while (!done) {
  // do something
}

terms of use | privacy policy | about | FAQ | blog | jobs | contact us
For 24/7 support email support@where.com or call 888-262-1150
WHERE™ is a product from uLocate Communications, Inc. ©2007 All Rights Reserved.