POV-Ray : Newsgroups : povray.general : Macro with variable number of parameters... : Re: Macro with variable number of parameters... Server Time
29 Jul 2024 12:18:42 EDT (-0400)
  Re: Macro with variable number of parameters...  
From: Margus Ramst
Date: 18 Jun 1999 15:33:19
Message: <376a9eff@news.povray.org>
I'd say it's not possible. Aside from the fact that a called #macro always
expects the same number of params specified in the original, there is a
problem of ambiquity. Let's say, out of 5 parameters the 3rd isn't
necessary. How would you go about omitting it?
The best I've managed was to have long parameters (strings or vectors) take
the value 0 as an alternative meaning "do not use". This, of course, is not
always applicable for vectors. Another thing is to make it possible to use,
for example, "3" instead of "<3,3,3>" by manually promoting the float to a
vector (#local Vector=Float+<0,0,0>;)
But what you want, I think is impossible.

Margus

con### [at] geocitiescom wrote in message
<376a8bf8$1$pbaarep$mr2ice@news.povray.org>...
>Is it possible to create a macro with a variable number of
>parameters?
>
>
>I'm trying to create a macro that counts the number of
>parameters passed to it and then issue the #macro definition.
>
>Is this possible?
>
>I want a way to make it so the user doesn't have to provide
>information that isn't necessary.  Based on the value of the
>first parameter, the second is always needed, but the third
>may not be.  I'd like to allow the user to do the following.
>
>myMacro(0,"a")
>
>or
>
>myMacro(1,"a","b")
>
>The first and second parameter are needed, but if the first is a 0
>(instead of a 1) the third value isn't necessary.
>
>Anyone have any ideas?
>
>--
>============================================================
>  Suburbia is where the developer bulldozes out the trees,
>  then names the streets after them.
>
>  -- Bill Vaughn
>============================================================
>   Friday, June 18, 1999 - 02:06 PM (EDT)
>============================================================
>
>_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~~~~~~~~~~-_
>+                                   +            +
>+   Chris C. Conner                 +    This    +
>+   cco### [at] amerisurecom-NOSPAM    +    space   +
>+   con### [at] geocitiescom-NOSPAM    +    for     +
>+   con### [at] usanet-NOSPAM          +    rent    +
>+                                   +            +
>~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-__________-~
>


Post a reply to this message

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