POV-Ray : Newsgroups : povray.programming : #ifdef(array[index]) : Re: #ifdef(array[index]) Server Time
29 Jul 2024 02:27:19 EDT (-0400)
  Re: #ifdef(array[index])  
From: Wayne Gordon
Date: 24 Oct 1998 20:15:30
Message: <36326070.7F3C@phoenix.net>
Mikael Carneholm wrote:
> 

> 
> #ifndef(array[index])
>    ...
> #end

This would be nice. You could try a workaround. Initialize all
elements to a dummy value that you are sure will never be a
legitimate value for any element, say 0, or a negative number.
Compare the value of array[index] to the dummy value to see
if you've re-assigned it a legitimate value. Of course, this could
waste alot of memory in some cases, depending on the size
of the array and what type of data the elements hold. 
You could also create an array of the same size as the one 
containing the data, but the elements of the second array reflect
the status of corresponding elements in the data array. I could
see using a string to contain information like this as well 
for a single dimension array of less than 255 elements, or you
could use arrays of strings for larger and more complex cases.
Desperation is the mother of invention!

> 
> or, alternatively, some way to convert strings to identifiers, like
> this:

Impossible.

> 
> #declare iteration=0;
> #while(iteration<10)
>    #ifdef(concat("variable_",str(iteration,0,0)))
>       ...
>    #end
>    #declare iteration=iteration+1;
> #end
> 
> ...which would allow me to see if variable_0, variable_1, variable_2
> etc. has been declared.

I'd stick with arrays...


Post a reply to this message

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