POV-Ray : Newsgroups : povray.general : array.length()? : Re: array.length()? Server Time
30 Jul 2024 18:19:12 EDT (-0400)
  Re: array.length()?  
From: clipka
Date: 25 Feb 2009 06:05:00
Message: <web.49a5259a78dc09aebdc576310@news.povray.org>
"Bill Pragnell" <bil### [at] hotmailcom> wrote:
> > > Just an extra thought - couldn't you globally #declare your array size
> > > when you populate it, then use this value in the second macro?
>
> "[GDS|Entropy]" <gds### [at] hotmailcom> wrote:
> > I had a version which did this, but I could only summon it once, as any
> > subsequent incarnations redefined the contents upon each call.
>
> I'm not sure I understand the problem... based on the first paragraph of your
> original post, if you keep track of the number of array elements in the first
> macro and #declare an array_size variable (not #local), then this number will
> be available for all subsequent code, just like the array, and you will know how
> many elements to loop through. If you call the same macro again, it will simply
> redefine this counter to reflect the new array contents... is this not what you
> want to do?
>
> I've got the vague feeling that I'm missing something, as this seems too easy a
> solution compared with other replies! :-)

Souns to me that he wants to use the same pair of macros over and over again and
therefore a single "global variable" to hold the array size wouldn't be enough.

I think testing for #ifdef(myArray[i]) is quite an elegant solution for the
problem: You just need the array, nothing more. "Global thinking" may be easier
for a quick hack, but is usually not so elegant in the long run. It's often an
obstacle when you want to turn code into a re-usable macro.


Post a reply to this message

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