POV-Ray : Newsgroups : povray.general : Pass array to macro. : Re: Pass array to macro. Server Time
25 Apr 2024 11:45:00 EDT (-0400)
  Re: Pass array to macro.  
From: Bald Eagle
Date: 12 Apr 2020 08:15:00
Message: <web.5e9306259cacd3d7fb0b41570@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> > Running this code raise en error :
> >    Parse Error: Expected '[', ,  found instead
> > for the line highlighted above

Correct and expected behaviour.

> > The macro drawLine can't understand that "thisLine" parameter is an
> > array of two elements.

It does, which is the problem.  It understands that thisLine is an array of the
dimensions that you specified, and you're supplying too few inices for it to
locate the element[s] that you want.

> > So it seems that i can't pass an array as a parameter to a macro ?

You totally can, I do it all the time.


> > Is my prognosis correct and is there any solution (other than split
> > array's item into two variables).

Hard to understand exactly what you mean, but:
All you do is pass the FULL array into the macro and then define the way you
address the parts of the array that you want to access.

If you only want to access the second dimension, then just hold the first one
constant, but you do have to put that into your ArrayName [index1][index2]
designation.

> you could declare an array of arrays, ie
> #declare ListOfLines = array [N] {
>   array [2] {point, point},
>   ...
>   array [2] {point, point}
> };

This I think would also be a way to avoid the error, and might be better, as you
can then have a parent array that is composed of sub-arrays of _different data
types_.    :)


Post a reply to this message

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