|
|
|
|
|
|
| |
| |
|
|
From: dick balaska
Subject: looking for sample code if nested #if #else #etc
Date: 28 Dec 2016 02:07:23
Message: <586364ab$1@news.povray.org>
|
|
|
| |
| |
|
|
I could have sworn I saw in the include menu samples (or somewhere in
the distribution) a wab of code like:
#if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
#if (yfoo=1) ybar1 #else #if (yfoo=2) ybar2 #end #end
#if (zfoo=1) zbar1 #else #if (zfoo=2) zbar2 #end #end
or somesuch. There were lots of nested #ifs on a single line, then
operated on the 3 axis. Maybe it was in a macro?
Anyway, my mighty povclipse parser threw up on that. I said "huh, I'll
have to get back to that" but I didn't make note of where I saw it.
Help?
--
dik
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 28.12.2016 um 08:07 schrieb dick balaska:
> I could have sworn I saw in the include menu samples (or somewhere in
> the distribution) a wab of code like:
> #if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
> #if (yfoo=1) ybar1 #else #if (yfoo=2) ybar2 #end #end
> #if (zfoo=1) zbar1 #else #if (zfoo=2) zbar2 #end #end
>
> or somesuch. There were lots of nested #ifs on a single line, then
> operated on the 3 axis. Maybe it was in a macro?
>
> Anyway, my mighty povclipse parser threw up on that. I said "huh, I'll
> have to get back to that" but I didn't make note of where I saw it.
No two `#end` directives on the same line in the entire official
distribution.
There is an `#if ( #if ( ... ) #end ) #end` construct mentioned in the
documentation about `#if`, but that very construct is only mentioned as
something kids shouldn't try at home, as it apparently sends even
POV-Ray's own parser reeling.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
dick balaska <dic### [at] buckosoftcom> wrote:
> I could have sworn I saw in the include menu samples (or somewhere in
> the distribution) a wab of code like:
> #if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
> #if (yfoo=1) ybar1 #else #if (yfoo=2) ybar2 #end #end
> #if (zfoo=1) zbar1 #else #if (zfoo=2) zbar2 #end #end
>
> ...
>
> Anyway, my mighty povclipse parser threw up on that. I said "huh, I'll
> have to get back to that" but I didn't make note of where I saw it.
>
I just tried this on my Windows 7 (64-bit) machine, using POV-ray v3.7, and it
works OK, no problems(!) I used only one of the three code lines...
#if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
.... but if it works for one, it should work for all three. (I don't *think* I've
ever used such a construct, though-- an #if(...)/#end inside of an #else(...) --
but it works on my system.)
Try this:
#version 3.7
global_settings {assumed_gamma 1.0}
camera {
perspective
location <0, 1, -4>
look_at <0, 0, 0>
right x*image_width/image_height
angle 67
}
light_source {
0*x
color rgb <1,1,1>
translate <20, 40, -20>
}
#declare xfoo = 1; // 1 or 2
#declare xbar1 =
sphere {0,1 pigment {srgb <.1,.5,.9>} finish {ambient .1 diffuse .9}} // BLUE
#declare xbar2 =
sphere {0,1 pigment {srgb <.5,.5,.5>} finish {ambient .1 diffuse .9}} // GREY
#if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Kenneth" <kdw### [at] gmailcom> wrote:
> dick balaska <dic### [at] buckosoftcom> wrote:
> > I could have sworn I saw in the include menu samples (or somewhere in
> > the distribution) a wab of code like:
> > #if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
> > #if (yfoo=1) ybar1 #else #if (yfoo=2) ybar2 #end #end
> > #if (zfoo=1) zbar1 #else #if (zfoo=2) zbar2 #end #end
> >
> > ...
> >
> > Anyway, my mighty povclipse parser threw up on that. I said "huh, I'll
> > have to get back to that" but I didn't make note of where I saw it.
> >
>
> I just tried this on my Windows 7 (64-bit) machine, using POV-ray v3.7, and it
> works OK, no problems(!) I used only one of the three code lines...
>
> #if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
>
> .... but if it works for one, it should work for all three. (I don't *think* I've
> ever used such a construct, though-- an #if(...)/#end inside of an #else(...) --
> but it works on my system.)
>
> Try this:
>
> #version 3.7
> global_settings {assumed_gamma 1.0}
>
> camera {
> perspective
> location <0, 1, -4>
> look_at <0, 0, 0>
> right x*image_width/image_height
> angle 67
> }
>
> light_source {
> 0*x
> color rgb <1,1,1>
> translate <20, 40, -20>
> }
>
> #declare xfoo = 1; // 1 or 2
>
> #declare xbar1 =
> sphere {0,1 pigment {srgb <.1,.5,.9>} finish {ambient .1 diffuse .9}} // BLUE
>
> #declare xbar2 =
> sphere {0,1 pigment {srgb <.5,.5,.5>} finish {ambient .1 diffuse .9}} // GREY
>
> #if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
I'm bad at writing SDL so I throw stuff together like this all the time and just
fix when an error occurs during parse time. Except that I know to use #elseif
instead of separate conditionals.
This gets interesting because I was able to get a pass on the following as well:
#declare xfoo = 0; // 0, 1 or 2
#declare xbar0 =
sphere {0,1 pigment {srgb <.9,.5,.1>} finish {ambient .1 diffuse .9}} // ORANGE
#declare xbar1 =
sphere {0,1 pigment {srgb <.1,.5,.9>} finish {ambient .1 diffuse .9}} // BLUE
#declare xbar2 =
sphere {0,1 pigment {srgb <.5,.5,.5>} finish {ambient .1 diffuse .9}} // GREY
#if (xfoo=1) xbar1 #else #if (xfoo=0) xbar0 #end #if (xfoo=2) xbar2 #end #end
//#if (xfoo=1) xbar1 #elseif (xfoo=2) xbar2 #end #if (xfoo=0) xbar0 #end
Commented line is a change to #elseif which also works okay. This sort of thing
is why I like the Ctrl+} (match brace) feature and would be great if same could
be done for #end.
Bob
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|