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
26 Apr 2024 06:33:16 EDT (-0400)
  Re: problem using ORs and strcmp() in #switch/#case  
From: Kenneth
Date: 7 Nov 2017 16:40:01
Message: <web.5a0226a21346e9e089df8d30@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
>
> > The problem seems to be with my use of ORs in the #case; they seem to be
> > screwing up the results somehow. The *successful* (strcmp(IMG_TYPE,AA) + 1000))
> > comparison value is being ignored or overridden, or something!
>
> Right - I think that you can't use case() like that.
>
> I think the Boolean comparison might yield a 0 or a 1, thus nothing
> ever returns 1000.

Well, both of these seem to work correctly (when not using the troublesome ORs,
that is)...
#switch(0)
#case(strcmp(IMG_TYPE,AA))

#switch(1000)
#case((strcmp(IMG_TYPE,AA) + 1000)

-- which in itself is actually kind of surprising, as I assumed #switch(0) would
be the equivalent of a 'false' statement Boolean-wise or in a TRUE/FALSE
comparison. That's why I didn't use #switch(TRUE)-- also because, with *that*,
the overal results--when USING the ORs--were screwy in a different way!
>
> Maybe you ought to do a regular
> #if (comparison1 | comparison2 | comparison3)
> #declare Trigger = 1000;
> #end
>

..... or just separate the various comparisons into individual #cases. I was
trying to avoid such stuff, simply because it didn't look... compact and elegant
 ;-)


Post a reply to this message

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