POV-Ray : Newsgroups : povray.advanced-users : variables in sdl Server Time
31 Oct 2024 08:19:29 EDT (-0400)
  variables in sdl (Message 1 to 4 of 4)  
From: [GDS|Entropy]
Subject: variables in sdl
Date: 23 Jan 2008 01:18:35
Message: <4796dc3b$1@news.povray.org>
Hello,

Is there some sort of way, other than to use a switch statement, to do this: 
[ignore the loop, its the variable I am interested in]

 #local var0 = foo;
 #local var1 = foo;
 #local var2 = foo;

while J<2{
 while Jx<num{
  #local Positions[J][Jx] = <0,var+J,0>; // so that it would be processed as 
var0 etc..
 }
}

Normally one could accomplish this quite easily in any other language...and 
I am guessing this is possible in sdl as well...

Thanks,
ian


Post a reply to this message

From: Warp
Subject: Re: variables in sdl
Date: 23 Jan 2008 03:19:46
Message: <4796f8a2@news.povray.org>
[GDS|Entropy] <gds### [at] hotmailcom> wrote:
>   #local Positions[J][Jx] = <0,var+J,0>; // so that it would be processed as 
> var0 etc..

> Normally one could accomplish this quite easily in any other language...and 
> I am guessing this is possible in sdl as well...

  I don't know of any language which would interpret "var+J" as anything
else than the sum of the values of 'var' and 'J'. Also, I don't know many
languages which support creating variable names from expressions and then
interpreting those variable names (maybe PHP is one of them).

-- 
                                                          - Warp


Post a reply to this message

From: Mike Williams
Subject: Re: variables in sdl
Date: 23 Jan 2008 05:21:08
Message: <qiVxa1BEUxlHFwZw@econym.demon.co.uk>
In most languages there'd be an eval() statement.

In POV SDL there's a nasty Parse_String() macro in strings.inc

#include "strings.inc"

#declare var0 = "foo";
#declare var1 = "bar";
#declare var2 = "baz";

#declare J=0;
#while (J<3)
   #declare A = concat("var",str(J,1,0));
   #debug concat(Parse_String(A),"\n")
   #declare J=J+1;
#end


It is much nicer, and more efficient, to create var as an array and use 
var[J].

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: [GDS|Entropy]
Subject: Re: variables in sdl
Date: 23 Jan 2008 14:10:57
Message: <47979141$1@news.povray.org>
Hey Warp,

Actually, you're right.
For some reason I was thinking of this:
"string" + variable + "string"

And logically, after a very long day, I completely invert the concept.
Sheesh...I really don't get enough sleep.

I do apreciate your help.

Ian

"Warp" <war### [at] tagpovrayorg> wrote in message 
news:4796f8a2@news.povray.org...
> [GDS|Entropy] <gds### [at] hotmailcom> wrote:
>>   #local Positions[J][Jx] = <0,var+J,0>; // so that it would be processed 
>> as
>> var0 etc..
>
>> Normally one could accomplish this quite easily in any other 
>> language...and
>> I am guessing this is possible in sdl as well...
>
>  I don't know of any language which would interpret "var+J" as anything
> else than the sum of the values of 'var' and 'J'. Also, I don't know many
> languages which support creating variable names from expressions and then
> interpreting those variable names (maybe PHP is one of them).
>
> -- 
>                                                          - Warp


Post a reply to this message

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