|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
|
|