|
|
Wasn't it [GDS|Entropy] who wrote:
>Hello,
>
>A little stuck here... evidently povray does not support any type of
>Return() function, and I am not familiar enough with sdl yet to figure this
>out any other way.
>This little macro does what it says, but not in this form.
>
>#macro isEvenOrOdd(integer)
> #if(mod(integer,2) = 0)
> #local isEven = 1;
> #else
> #local isOdd = 1;
> #end
>#end
>
>There HAS to be some way to pass variables from a macro...right? :-\
You're confusing the concept of MACRO with the concept of FUNCTION.
The entire contents of a macro are "returned", so you can write:
#macro isEven(integer)
#if(mod(integer,2) = 0)
#local even = 1;
#else
#local even = 0;
#end
(even)
#end
#if (isEven(3))
#debug "3 is even\n"
#else
#debug "3 is odd\n"
#end
Or
#macro isOdd(integer)
(mod(integer,2))
#end
#if (isOdd(3))
#debug "3 is odd\n"
#else
#debug "3 is even\n"
#end
Don't get confused into thinking that those macros get evaluated and
then return integer values. They "return" chunks of SDL code like
#if(mod(3,2) = 0) #local even=1; #else #local even = 0; #end (even)
And what happens is that
#if (isEven(3))
effectively becomes
#if (#if(mod(3,2) = 0) #local even=1; #else #local even = 0; #end
(even))
and THEN gets evaluated.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|