POV-Ray : Newsgroups : povray.programming : #ifdef(array[index]) Server Time
29 Jul 2024 04:27:28 EDT (-0400)
  #ifdef(array[index]) (Message 1 to 6 of 6)  
From: Mikael Carneholm
Subject: #ifdef(array[index])
Date: 22 Oct 1998 10:16:13
Message: <362F2EA6.5AF2@ida.utb.hb.se>


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

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

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

- Mikael.


Post a reply to this message

From: Wayne Gordon
Subject: Re: #ifdef(array[index])
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

From: Ronald L  Parker
Subject: Re: #ifdef(array[index])
Date: 25 Oct 1998 00:33:10
Message: <36329b58.25693363@news.povray.org>
On Sat, 24 Oct 1998 18:19:12 -0500, Wayne Gordon <way### [at] phoenixnet>
wrote:

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

Not impossible.  Just not useful except as a workaround for the lack
of other data types.  For examples of languages that can do this (but 
in which most people wisely choose not to) see Perl or Lisp and look
at the 'eval' function.


Post a reply to this message

From: Wayne Gordon
Subject: Re: #ifdef(array[index])
Date: 25 Oct 1998 07:23:15
Message: <36331919.1CF5@phoenix.net>
Ronald L. Parker wrote:
> 
> On Sat, 24 Oct 1998 18:19:12 -0500, Wayne Gordon <way### [at] phoenixnet>
> wrote:
> 
> >> or, alternatively, some way to convert strings to identifiers, like
> >> this:
> >
> >Impossible.
> 
> Not impossible.  Just not useful except as a workaround for the lack
> of other data types.  For examples of languages that can do this (but
> in which most people wisely choose not to) see Perl or Lisp and look
> at the 'eval' function.

I meant that it was impossible to do in POV's scripting language
right now, not necessarily impossible in another language. POV can 
convert the contents of a string to a numerical value and assign
that value to a variable, but it is not possible to convert a string
to an identifier as was asked.


Post a reply to this message

From: Dan Connelly
Subject: Re: #ifdef(array[index])
Date: 25 Oct 1998 19:39:48
Message: <3633C497.75505AC5@flash.net>
It's quite possible.

Use file i/o to generate an .inc file, then include
it.

But it would get ugly....

Dan

Wayne Gordon wrote:
> 
> Ronald L. Parker wrote:
> >
> > On Sat, 24 Oct 1998 18:19:12 -0500, Wayne Gordon <way### [at] phoenixnet>
> > wrote:
> >
> > >> or, alternatively, some way to convert strings to identifiers, like
> > >> this:
> > >
> > >Impossible.
> >
> > Not impossible.  Just not useful except as a workaround for the lack
> > of other data types.  For examples of languages that can do this (but
> > in which most people wisely choose not to) see Perl or Lisp and look
> > at the 'eval' function.
> 
> I meant that it was impossible to do in POV's scripting language
> right now, not necessarily impossible in another language. POV can
> convert the contents of a string to a numerical value and assign
> that value to a variable, but it is not possible to convert a string
> to an identifier as was asked.

-- 
http://www.flash.net/~djconnel/


Post a reply to this message

From: Wayne Gordon
Subject: Re: #ifdef(array[index])
Date: 26 Oct 1998 16:27:47
Message: <3634EA47.4804@phoenix.net>
Dan Connelly wrote:
> 
> It's quite possible.
> 
> Use file i/o to generate an .inc file, then include
> it.

Ahhh, yes. I dind't think of this, obviously. I stand corrected.

> 
> But it would get ugly....

Indeed.

> 
> Dan
> 
> Wayne Gordon wrote:
> >
> > Ronald L. Parker wrote:
> > >
> > > On Sat, 24 Oct 1998 18:19:12 -0500, Wayne Gordon <way### [at] phoenixnet>
> > > wrote:
> > >
> > > >> or, alternatively, some way to convert strings to identifiers, like
> > > >> this:
> > > >
> > > >Impossible.
> > >
> > > Not impossible.  Just not useful except as a workaround for the lack
> > > of other data types.  For examples of languages that can do this (but
> > > in which most people wisely choose not to) see Perl or Lisp and look
> > > at the 'eval' function.
> >
> > I meant that it was impossible to do in POV's scripting language
> > right now, not necessarily impossible in another language. POV can
> > convert the contents of a string to a numerical value and assign
> > that value to a variable, but it is not possible to convert a string
> > to an identifier as was asked.
> 
> --
> http://www.flash.net/~djconnel/


Post a reply to this message

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