for - Used to loop until a certain condition is met.
for (i=0;i<10;i+=2) do … endfor
for i in variable do …endfor
for i function(…) do … endfor
In the first form, the "for function" is used to loop until the condition is met. The first part is the initialization. The second part is the test and the third part is done at the end of the loop before the condition. ( and ) are mandatary.
In the second form, the "for function" is used to loop for each elements of the variable.
In the third form, the "for function" is used to loop until the function returns "false". At each iteration, the result of the function is returned and put in the variable i.
The loop initializes variables:
Note: In the followings examples, the _ between the { should be removed to make it work.
for(i=0,j=10;i<10&&j>0;++i,--j) do .... endfor
for i in [1,2,4] do " nb="; sn_nb; " i="; i; endfor
return
res= nb=0 i=1 nb=1 i=2 nb=2 i=4.
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>
1.0 2014-09-09 21:24:14 laplante@sednove.com
Edit© 2024 extenso Inc. All rights reserved.