POV-Ray : Newsgroups : povray.general : Problem with parameters : Re: Problem with parameters Server Time
31 Jul 2024 00:33:00 EDT (-0400)
  Re: Problem with parameters  
From: Tim Attwood
Date: 26 Feb 2008 23:56:21
Message: <47c4ed75$1@news.povray.org>
>> #macro DoCalc(pZ,pY,I,N) //function arbitrarily choosen
>>   #local pY= y*cA*sin(2*pi*cFr*I/N+cFs);
>>   #local pZ= z*L*I/N;
>> #end
> ...
>
> Note that this macro should (AFAIK) have no effect in any scene.
>
> If it has, then that might be a bug in the POV-Ray version you
> are using.
>
> (You are just setting 2 local variables that are "lost" right
> afterwards when the macro is exited.)

That isn't exactly right, pY and pZ are being returned by
parameter.

Unfortunately in 3.6 passing values by parameter is buggy,
it's fixed in the 3.7 beta, but in general you probably shouldn't
rely on values being returned correctly via parameter.

Typically you can either globally #declare a value to return,
or return a value by subsitution like this...

#macro DoCalcY(pZ,pY,I,N)
   #local result = y*cA*sin(2*pi*cFr*I/N+cFs);
   (result)
#end

#macro DoCalcZ(pZ,pY,I,N)
   #local result = z*L*I/N;
   (result)
#end

And call the calculations...

#local pY = DoCalcY(pZ,pY,I,N);
#local pZ = DoCalcZ(pZ,pY,I,N);


Post a reply to this message

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