POV-Ray : Newsgroups : povray.newusers : Newbie question about functions : Re: Newbie question about functions Server Time
2 Jul 2024 21:42:33 EDT (-0400)
  Re: Newbie question about functions  
From: clipka
Date: 20 Dec 2010 05:06:46
Message: <4d0f2ab6$1@news.povray.org>
Am 20.12.2010 07:49, schrieb TheBigH:
> Why does this not work? It complains that I need to initialize X and Y before I
> call them in the macro Fracp, but since I am passing them as parameters to the
> function Gridd this would obviously be inappropriate. I have also tried changing
> the macro into another function, but that doesn't work either.
>
>
> #declare thick=0.05;
> #macro Fracp(A)
>   A-floor(A)
> #end
> #declare Gridd = function( X, Y ) {
>   #if ( Fracp(X)<thick | Fracp(X)>(1-thick) | Fracp(Y)<thick | Fracp(Y)>(1-thick)
> )
>     1
>   #else
>     0
> #end
> }

Note that "#" statements are always evaluated at parsing time, even when 
used in a function. Therefore, "#if" statements cannot be used to 
perform tests inside functions at run-time.

You will need to use the "select" function to have the condition 
evaluated each time the function is called.


Post a reply to this message

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