POV-Ray : Newsgroups : povray.general : Macro Initialization? : Re: Macro Initialization? Server Time
10 Aug 2024 13:26:14 EDT (-0400)
  Re: Macro Initialization?  
From: Chris Colefax
Date: 13 Feb 2000 01:19:14
Message: <38a64ce2@news.povray.org>
Bill DeWitt <the### [at] earthlinknet> wrote:
> I want to use macros in a way that they probably can't be used. I only ask
> because every time I don't, it turns out that what I want to do is quite
> easy and everyone but me has been doing it all along...
>
> I want to call the macro with only those values that are relevant to it's
> present use. For instance...
>
> gadget(knobs)
> gadget(knobs,lights,dials)
> gadget(dials,dial_light,dial_needle,dial_range)
>
>     ... where everything not specified is assumed. This is because I want
to
> make some macros with a couple dozen possible fields and I don't want to
> have to list every one of them every time.

I had the same problem when I started creating my Spline macro system.  With
my previous (non-macro) include files a set of declarable options worked
well, but it was easy to forget or mistype option variable names, and a
hassle to enter all the #declare ... = ... statements.

If your options are all boolean values then one solution is to code a system
of bitwise operators (as I have in the City Generator).  For more
flexibility, I've created a system for the aforementioned Spline macros
that allows you to specify named options and values, without having to use
any #declare or #local statements.  The technique also catches mistyped
option names as parsing errors, and allows you to specify options ranging
from floats and vectors to objects, pigments, arrays, strings, etc.

If you want to try the technique (and the Spline system), email me for a
copy of the macro file - it's still not finished, but any testing you might
want to do is most appreciated.


Post a reply to this message

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