Mioplanet Documentation Center
Resources and Help
HomeProductsMioScriptJavaScriptTechNotesPHP
   Home | MioScript | for SEARCH    

  Functions
?
doEvent.eventName
event.end
event.eventName
for
for.exit
for.next
function.end
function.functionName
if
if.else
if.end
return
while
while.end
while.exit

  MioScript Reference
> Statements
app...
browser...
dialog...
disk...
draw...
extern...
filename...
keyboard...
menu...
mio...
mouse...
num...
path...
pushButton...
reg...
RS232...
sci...
screen...
shortcut...
sound...
str...
system...
time...
var...
window...

Statement
for

Language: MioScript
Product: MioFactory


Syntax

for(variableName, firstValue, lastValue, step)


Parameters

VARIABLEvariableNameName of a variable
INTfirstValueInitial value of the variable variableName.
INTlastValueFinal value of the variable variableName.
If step is positive, The loop is completed when variableName is greater or egual to LastValue.
If step is negative, The loop is completed when variableName is lower or egual to LastValue.
INTstepOptional.
Positive or negative number to be added to the variable each time the loop is repeated.
Default value is 1.


Return value

No value is returned.


Description

Repeats a block of code and increment or decrement a variable while the final value is not reached.

See also: for.next, for.exit

More information: MioScript: Loops




MioScript Sample Code

// The block of code is repeated 10 times.
// The value of <I>&ptr</I> is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

for(&ptr, 0, 10)
    // Block of code
for.next


// The block of code is repeated 10 times.
// The value of <I>&ptr</I> will be 10, 9, 8, 7, 6, 5, 4, 3, 2, 1.

for(&ptr, 10, 0, -1)
    // Block of code
for.next


// The block of code is repeated 5 times.
// The value of <I>&ptr</I> will be 0, 2, 4, 6, 8.

for(&ptr, 10, 0, -1)
    // Block of code
for.next


// The block of code is not executed.

for(&ptr, 0, 0)
    // Block of code
for.next