|
 |
In article <397DA722.A87A6A01@peak.edu.ee>, Margus Ramst
<mar### [at] peak edu ee> wrote:
> #macro a(foo)
> #if (foo)
> #declare Switch=1;
> #else
> #declare Switch=0;
> #end
> #end
>
> #if(Switch)
> #macro b()
> // do one thing
> #end
> #else
> #macro b()
> // do another thing
> #end
> #end
In that case, you have to use that #if() statement after every time you
call a(). Not very user-friendly...a better solution would be this:
// set a "default" macro
#declare Switch = 1;
#macro B1(foo)...#end
#macro B2(foo)...#end
#macro A(Foo)
#if(Foo)
#declare Switch = 1;
#else
#declare Switch = 2;
#end
#end
// Code which would be calling B() if nested declarations were allowed.
#if(Switch == 1)
B1(Foo)
#else
B2(Foo)
#end
And of course, for more than two versions of the macro, you simply use a
#switch() statement. You could even put this in yet another macro, to
hide the fact that one of several macros is being picked, like this:
#macro B(Bar)
#if(Switch == 1)
B1()
#else
B2()
#end
#end
Another possible workaround would be to put the macros in separate
include files, and have a macro include different files depending on
which one you want. You can't nest a #macro within a #macro, but maybe
you can nest a #macro within an #include within a #macro...I haven't
actually tried it, though, and it seems like a messy way to code.
--
Christopher James Huff - Personal e-mail: chr### [at] mac com
TAG(Technical Assistance Group) e-mail: chr### [at] tag povray org
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/
Post a reply to this message
|
 |