POV-Ray : Newsgroups : povray.newusers : Incrementing variables in #for loop : Re: Incrementing variables in #for loop Server Time
19 Apr 2024 03:48:09 EDT (-0400)
  Re: Incrementing variables in #for loop  
From: Alain Martel
Date: 27 Mar 2020 11:52:44
Message: <5e7e214c$1@news.povray.org>
Le 2020-03-26 à 19:36, Bald Eagle a écrit :
> 
> So, I came across a strange complaint from the POV-Ray parser. (qtpovray 3.8)
> 
> I have a standalone file that makes the virus particle for jr's animation.
> Works fine.
> 
> I copied and pasted the object definition into an include file, and I was
> suddenly getting the "Parse Error: Cannot pass uninitialized identifier to
> non-optional LValue." error.
> 
> When I change the #local in the loop to a #declare, it works.
> 
> before the loop:
> #declare dlong = pi*(3-sqrt(5));  //~2.39996323
> #declare dz = 2/N;
> #declare long = 0;
> #declare Z = 1 - dz/2;
> 
> // ....
> 
> #declare COVID_19 = union {
> #for (k, 0, N-1)
> 
> // ....
> // and here we have the #local vs #declare problem:
> 
>   #local Z = Z - dz;
>   #local long = long + dlong;
> #end
> }
> 
> 
> I'm not sure why it would work in one scene, and not the other.
> It's as if the loop or the #local somehow negates the global name, but only in
> the include file.   :O
> 
> 
The #local in the loop is local to the loop and temporarily replace the 
global version of th evariable.

Replace the #declare in the .inc by #local for all variables that are 
used in the .inc
This will prevent the accidental alteration of your global variables.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.