|
|
In a macro, is it possible to define default values for parameters, so they
can be skipped during instantiation?
#macro Laser (Color = 'Red')
body here
#end
so that calling:
Laser() would produce a Red laser,
Laser(Green) would produce a Green laser, and so forth?
This doesn't work, of course, but some other way?
Alan Walkington
Post a reply to this message
|
|
|
|
Wasn't it Alan Walkington who wrote:
>In a macro, is it possible to define default values for parameters, so they
>can be skipped during instantiation?
>
>#macro Laser (Color = 'Red')
> body here
>#end
>
>so that calling:
>
>Laser() would produce a Red laser,
>Laser(Green) would produce a Green laser, and so forth?
>This doesn't work, of course, but some other way?
One way is to allow the variables to be declared outside the macro call,
and use #ifdef/#ifndef to see if they are declared. Something like this:
#macro Laser
#ifndef (Laser_Colour)
#local Laser_Colour = Red;
#end
body here
#end
or
#macro Laser
#ifndef (Laser_Colour)
#declare Laser_Colour = Red;
#end
body here
#undef Laser_Colour
#end
In the second version, the macro undefines the copy of Laser_Colour that
exists in the calling code, so that the next laser will default back to
Red, whereas in the first version the laser defaults to the previously
selected colour.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
|
|
In article <3e90dc87@news.povray.org>,
"Alan Walkington" <alan[REMOVE]@walkington.net> wrote:
> In a macro, is it possible to define default values for parameters, so they
> can be skipped during instantiation?
No. You have to make separate versions of the macro (with different
names...no name overloading in POV), or use some flag value to tell the
macro to use a default value.
--
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/
Post a reply to this message
|
|