|
|
How about this:
write your own Parse_String which always outputs to
"somefile.ext".
Then do:
#ifndef (#include"somefile.ext")
I'm not quiet sure if that'll work though.
As for the last part of your post:
#declare Parse_String... = ...
processes down to
#declare #include "blabla" = ...
So, I'd expect it to complain. Hm, which might
be a reason for #ifndef to complain for the above:
#ifndef (#include"...") ?
You've got to experiment. Perhaps writing the entire
#ifndef () ... #debug ".." #end
to disc and #including that.
Regards,
Tim
--
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de
"Florian Brucker" <tor### [at] torfboldcom> schrieb im Newsbeitrag
news:3f5f4f76$1@news.povray.org...
> Hey Guys!
>
> I want to check if a certain pigment is already defined and otherwise
> define it. Normally that would be no problem, #ifndef does the job.
>
> Unfortunately, I create my pigments dynamically within the SDL code.
> Every pigment gets a number. The pigment's name would be
>
> Parse_String(concat("Pigment",str(Number,0,0)))
>
> but this does not work with #indef. The following code reports: "Parse
> Error: Expexted ')', '(' found instead". The error occurs right after
> "Parse_String" in the code:
>
> <code>
> #include "strings.inc"
>
> #local Number = 34;
> #local PigmentName = concat("Pigment",str(Number,0,0));
>
> #ifndef(Parse_String(PigmentName))
> #debug "no pigment defined, yet\n"
> #end
> </code>
>
> I understand this from the parser's point of view - normaly, opening
> brackets inside #ifndef() do not make sense, as identifiers aren't
> allowed to contain brackets. In the case of Parse_String(), however,
> it makes sense.
>
> I see no reason to rewrite the parser because of this, but I'd like to
> know if there is another possibility to check if an identifier from
> which I got only the name as a string is already declared.
>
> BTW, declaring such an identifier is possible: while
>
> <code>
> #declare Parse_String(PigmentName) = pigment { rgb<1,0,0> }
> </code>
>
> gives an error,
>
> <code>
> Parse_String(concat("#declare ",PigmentName)) = pigment { rgb<1,0,0> }
> </code>
>
> works perfectly.
>
> Thanks in advance,
> Florian
> --
> //=================[web: http://www.torfbold.com]==================\\
> #local a=-5;#while(a<5)sphere{<sin(a*pi)*5a*10pow(a,5)*.01>sin(a*a*a*
> .1)+1pigment{rgb 9*z}}#local a=a+.01;#end camera{look_at-y*10location
> <8,-3,-8>*10}// [www.povray.org] [www.imp.org] [www.irtc.org]
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01.09.2003
Post a reply to this message
|
|