POV-Ray : Newsgroups : povray.advanced-users : problem using ORs and strcmp() in #switch/#case : Re: problem using ORs and strcmp() in #switch/#case Server Time
29 Apr 2024 09:46:34 EDT (-0400)
  Re: problem using ORs and strcmp() in #switch/#case  
From: Bald Eagle
Date: 8 Nov 2017 10:10:00
Message: <web.5a031d721346e9e0c437ac910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:

> > In fact, check out:
> >
> >     #switch(strcmp(IMG_TYPE,BB) | strcmp(IMG_TYPE,CC) )
> >
> >      #case(-10)
> >      rgb <1, 1, 0>
> >     #break
> >
> >      #case(-6)
> >      rgb <1, 1, 1>
> >     #break
> >
> >     #case(1)
> >      rgb <0, 0, 0.2>
> >     #break
> >
> >     #case(1000)
> >
> > It selects the blue pigment, which corresponds to 1.
>
> *That's* a really unexpected result, IMO; neither of the #switch's strcmp()s
> 'match' IMG_TYPE (which would be AA), yet #case(1) is chosen as if #switch is
> 'true.' And looking at it in a different brain-twisting way (one that's
> incorrect, no doubt), it seems that either #case(-6) or #case(-10) should be
> chosen, but certainly not #case(1)

It seems to me that none of the individual cases should be chosen, as neither of
the Boolean expressions evaluate to 1, which means the logical OR should return
zero - so -10, -6, 1, and 1000 should ALL be skipped, and any extant #else
should selected instead.

No POV-Ray on _this_ computer, so I can't test anything for the next 8 hours.
(which is why I'd love a simple editor/parser-no-render combo, or a true
stand-alone POV-Ray ("USB") version)


Post a reply to this message

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