|
|
Kenneth wrote...
> #switch(0)
> #case(strcmp(IMG_TYPE,AA)=0)
>
> I ask because the latter doesn't work--no error message of any kind is created,
> but it falls through to the #else clause, even though strcmp(IMG_TYPE,AA) is a
> 'match' between IMG_TYPE and AA.
Bald Eagle wrote...
> Which means that it evaluates to TRUE, or 1, which is NOT 0.
> Stop thinking in terms of conditional Boolean word results, and think in 0 or 1.
> #if (strcmp(IMG_TYPE,AA)=0)
> would give a Boolean result of 1.
And Clipka wrote...
> If IMG_TYPE is equal to AA, then `strcmp(IMG_TYPE,AA)` will yield 0.
> Comparing that result with zero will yield true, i.e. some non-zero number.
Ah! OK, this finally makes sense to me! Thanks to you both. (All of this stuff
reminds me of my college days, when I struggled mightily to grasp the
complexities of Boolean operations. Ugh. It made my brain hurt then too.)
Kenneth wrote...
> I didn't know that using #cases without #breaks was possible :-O Thanks!
> ...a note in the documentation about it would be justified ;-)
Clipka...
> It's hinted at very briefly in the v3.7 docs.
Oops, you're right (as I see after re-reading the docs for the 137-th
time...ha...)
"If a clause evaluates true but no #break is specified, the parsing will fall
through to the next #case or #range and that clause conditional is evaluated."
So apparently it also works if a clause evaluates 'false' (the pseudo-OR
behavior.)
Post a reply to this message
|
|