POV-Ray : Newsgroups : povray.general : Macro Parameters Server Time
4 Nov 2024 17:33:46 EST (-0500)
  Macro Parameters (Message 1 to 4 of 4)  
From: BC
Subject: Macro Parameters
Date: 5 Feb 1999 03:37:28
Message: <01be50e2$ee9dc2e0$0c0b010a@angela>
Can anyone tell me how you pass an array to a macro. I have looked at the
docs, and they don't say you can't, but I can't figure out the syntax to do
so.

Thanks
Gordon
<gor### [at] hotmailcom>


Post a reply to this message

From: Spider
Subject: Re: Macro Parameters
Date: 5 Feb 1999 05:35:10
Message: <36BAC834.373EB0F1@bahnhof.se>
BC wrote:
> 
> Can anyone tell me how you pass an array to a macro. I have looked at the
> docs, and they don't say you can't, but I can't figure out the syntax to do
> so.
here it is.
there is a float function to get the amount of posts in the array that
can be useful for you.
Othreways, pov doesn't care, as long as you access it as a normal array.
#mcaro(InputArray)
 //insert code
#end

//Spider


Post a reply to this message

From: John VanSickle
Subject: Re: Macro Parameters
Date: 7 Feb 1999 14:28:11
Message: <36BDEA43.B2B38108@erols.com>
BC wrote:
> 
> Can anyone tell me how you pass an array to a macro. I have looked at the
> docs, and they don't say you can't, but I can't figure out the syntax to do
> so.

It's easy.  Just pass the label for the array, and index into it within
the macro.

For instance you can declare it as follows:

#macro Average(Array)
  #local I=1;
  #local Sum=Array[0]; // so that Sum is created as the same type as Array[]
  #while (I<dimension_size(Array,1))
  #local Sum=Sum+Array[I];
  #local I=I+1;
  #end
  (Sum/I)
#end

And then use it like this:

#declare BugaBoo=array[4] { 34,5,-17,8 }
#declare BugaBee=array[3] { <1,0,3>,x+y, <.3,.3,-.1>+z*2 }

#local s_ScalarAverage=Average(BugaBoo);
#local s_VectorAverage=Average(BugaBee);

Hope this helps,
John


Post a reply to this message

From: BC
Subject: Re: Macro Parameters
Date: 8 Feb 1999 23:59:56
Message: <01be53e9$453c07c0$0c0b010a@angela>
Thanks for that. Obvious once someone points it out, isn't it.

Gordon

John VanSickle <van### [at] erolscom> wrote in article
<36BDEA43.B2B38108@erols.com>...
> BC wrote:
> > 
> > Can anyone tell me how you pass an array to a macro. I have looked at
the
> > docs, and they don't say you can't, but I can't figure out the syntax
to do
> > so.
> 
> It's easy.  Just pass the label for the array, and index into it within
> the macro.
> 
> For instance you can declare it as follows:
> 
> #macro Average(Array)
>   #local I=1;
>   #local Sum=Array[0]; // so that Sum is created as the same type as
Array[]
>   #while (I<dimension_size(Array,1))
>   #local Sum=Sum+Array[I];
>   #local I=I+1;
>   #end
>   (Sum/I)
> #end
> 
> And then use it like this:
> 
> #declare BugaBoo=array[4] { 34,5,-17,8 }
> #declare BugaBee=array[3] { <1,0,3>,x+y, <.3,.3,-.1>+z*2 }
> 
> #local s_ScalarAverage=Average(BugaBoo);
> #local s_VectorAverage=Average(BugaBee);
> 
> Hope this helps,
> John
>


Post a reply to this message

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