|
 |
Thanks for that. Obvious once someone points it out, isn't it.
Gordon
John VanSickle <van### [at] erols com> 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
|
 |