In FOR loops


I have just found out someting interesting writing a script.
This is about a variable i in a loop.

Example :
  Given a function drawObject(x,y) with
     for ( i = 1; i < n+1; i++)
     { // code which acts with i }

In onLoad(), I have written a loop to draw 10 objects calling drawObject :
for ( i = 0; i < 10; i++)
{ // code to reckon x et y (depends on i )
    // then call drawobject(x,y)
We yield only 1 object instead of 10 !

Why ? I don't know I put a finger on it but I have fixed up the trouble with a different name of the variable in one loop.
For instance, for ( j = 1; j < n+1; j++) in drawObject
Yet, these loops are not included, but it acts as if. Bug, huh ?
Coming from C++ and PHP world, it's a tough time.


Member of the Anti Hacker Alliance

Select a language if you need :

Page chargée en 0.001 sec.

Dernière Modification : Ven 7 Aout 2020 8:30
Copyright © 1999-2020 Jean-Paul Molina Tous droits réservés.

to Google