POV-Ray : Newsgroups : povray.newusers : local variables in macros : Re: local variables in macros Server Time
4 Nov 2024 23:19:49 EST (-0500)
  Re: local variables in macros  
From: Nikodemus Siivola
Date: 21 May 2001 03:05:38
Message: <3b08be42@news.povray.org>
"Elias Pschernig" <eli### [at] aonat> wrote in message
news:3b0832ce$1@news.povray.org...

> I was avoiding one line of code for every parameter. And i'm going to
> need lots of parameters, as there doesn't seem to be a
> 'record/struct/class' construction in POV :)

There are the arrays, though...

> #macro example(pos)
>    #local var_pos = pos // this is what i have to do additionally
>    #while
>       example(var_pos)
>       #local var_pos = var_pos + y // because this should change the
>                                    // local value only
>    #end
> #end

Some notes:
- As per docs, you should use #declare var_pos... within the loop to
redefine the local variable.
- Even tough the docs don't properly cover what happens when you use #local
to redefine local variables within loop, it seems to work equivalently to
the above. Note though, that MegaPOV seems have trouble with #undef after
doing this. 3.1g works seems to treat #local for the purpose of redefining
local variables just as it does #declare. I suspect that it may result in
strangeness as well. ;)

 -- Nikodemus


Post a reply to this message

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