POV-Ray : Newsgroups : povray.newusers : Incrementing variables in #for loop : Re: Incrementing variables in #for loop Server Time
20 Sep 2021 11:18:58 EDT (-0400)
  Re: Incrementing variables in #for loop  
From: Alain Martel
Date: 27 Mar 2020 11:59:34
Message: <5e7e22e6$1@news.povray.org>
Le 2020-03-27 à 07:03, Bald Eagle a écrit :
> 
> "jr" <cre### [at] gmailcom> wrote:
> 
>> docs 3.3.2.2.2 "declare vs local", see paragraph beginning with "Use of #local
>> within an include file ...".  (no different, afaict, from being within a macro)
> 
> 
> I considered the ephemeral nature and scope, but if it does indeed apply, then I
> don't currently see how.  We're definitely looking for the problem/solution in
> the same place.
> 
> The #declare of Z ought to create a Z that persists in all parts of the scene
> file.
> Even if it didn't, I'm still in the inc file that I created it in, so in theory
> I ought to be able to (and should) use #local (but I'm still in early
> development).
> 
> #local Z = Z - dz; ought to work because we're still IN the inc file, and IN the
> loop - and THAT works in the standalone scene (where I'd think the same #local
> issue would apply).   Otherwise I'd have to do some wacky #local Z = global(Z) -
> dz; which obviously has it's own failure, and how would you do a #while?
> 
> Once the whole loop is complete, I don't need Z or long, because I'm done
> defining the object.
> 
> 
> 
> 

The #local Z = Z - dz; is local to the for loop and distinct from the 
variable created with the #declare Z = 1 - dz/2;
As soon as the local Z is declared, the global Z becomes invisible or 
hidden. That local Z disappears as soon as you exit the for loop.

So, in your include, use only #local and only use #declare if you want 
to affect the global instance of your variables, like when you want to 
pass back some computed values.


Post a reply to this message

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