|  |  | Alain <aze### [at] qwerty org> wrote:
> As you probably don't need the indexing variables outside the
> initialisation, and you surely don't need to keep the final values, you
> can use #local.
> That way, the variables will not exist once the loops are terminated.
This is true of macros and include files.  It does not apply to loops.
Try this scene file:
_________________________________________
#declare MyArray = array[5][10];
#local I = 0;
#while (I < 5)
   #local J = 0;
   #while (J < 10)
      #declare MyArray[I][J] = 0;
      #local J = J + 1;
   #end
   #local I = I + 1;
#end
text
{  ttf "cyrvetic.ttf" str(I,0,1) 0.001, 0
   translate <-1, 0.2, 2>
   pigment { rgb 1 }
   finish { ambient 1 }
}
text
{  ttf "cyrvetic.ttf" str(J,0,1) 0.001, 0
   translate <-1, -0.8, 2>
   pigment { rgb 1 }
   finish { ambient 1 }
}
_________________________________________
The identifiers I and J can be referenced even after the loops are closed.  J
can be referenced even though it's declared only inside the I loop. Post a reply to this message
 |  |