|
|
Is it possible to use a string construction of some kind to generate a VARIABLE
NAME (or identifier, as POV-Ray calls it) that can be used after a #declare?
So that, instead of
#declare my_value = 12345;
I could do this...
#declare --generated string name-- = 12345;
So far, I have had no luck. (Maybe I'm forgetting something basic??)
As a more practical example, say I want to create 100 different arrays inside of
a #while loop-- each with a different #declared name of course-- but without
having to manually name each and every array. Creating the different names
themselves is no problem when using strings (assume that AC is a #while loop
counter, simple up-counting integers)...
#declare array_name = concat("my_array",str(AC,1,0))
The generated string changes as AC changes, and array_name becomes my_array1,
my_array2, etc. But these are just names-as-strings, with no arrays 'attached'
yet. When I then try to create the arrays themselves...
#declare array_name = array[100]
......array_name is just #re-declared at every count of the while loop (it
doesn't substitute my_array1 for it, then my_array2 etc) which defeats the idea;
the end result is a *single* array that's simply re-declared over and over
again.
Trying to simplify the idea to this rather strange construction doesn't work
either (it produces a fatal error)...
#declare concat("my_array",str(AC,1,0)) = array[100]
So, if not with strings, is there another way to do this kind of automated
identifier creation?
------
While I'm on this subject: I see that I cannot substitute a string for one of
POV-Ray's built-in keywords-- like rgb or whatever. For example:
#declare color_vector_type = "rgb"
which I could then use in a pigment statement...
pigment{color_vector_type <.3,.6,.9>}
I would have assumed that this was possible, simply because... 'text is text':
When I type the letters rgb on the keyboard, its just text. (But then, of
course, POV-Ray recognizes what I've typed, and substitutes a keyword for it.)
So... what are the essential differences between typing r-g-b, the string "rgb",
and the keyword rgb? Perhaps it's a very naive question! (Maybe one that would
require a textbook in C-programming to explain??)
Post a reply to this message
|
|