|
|
"Kenneth" <kdw### [at] gmailcom> wrote:
-- mainly because there's a specific stumbling
> block or two that's giving me a problem.
Yes, because you're doing that weird thing with #switch(), which erects the
stumbling block.
> My basic question is: When is the #switch() value considered an actual Boolean
> true/false value, vs. a 'simple numerical' value?
The #switch() value isn't the thing that's the Boolean value.
The result of the comparison of the #case() with the #switch() is.
Imagine that they are all
#if ( #switch(Trigger) = #case(ThisSpecificCase) )
#elseif()
#end
> consider the following:
> #declare C = 27;
> (A)
> This works successfully...
> #switch(1) // Boolean 'true'
> #case(C = 27) // a Boolean comparison that's also 'true'
normally this would be "phrased" as:
#switch (C)
#case (27)
#break
#end
> (B)
> This ALSO works... two 'numerical values' that match
> #switch(27)
> #case(C)
Similar to the above, although an interesting reversal.
I've never thought to do it that way, but it may open up interesting
possibilities... :)
> (C)This does NOT work (it falls through to the #else clause)...
> #switch(1000) // or 343 or -89 or any other non-zero value
> #case(C = 27) // the Boolean comparison again
....or any non-ONE value.
because (C=27) evaluated as a Boolean comparison is true, which results in a
value of 1. And as jr pointed out, 1000 <> 1, or 1000 != 1, however you want
to write it...
> Regarding (A) and (B), it appears that #switch 'changes its operational mode'--
> depending on the particular 'kind' of #case that it's presented with (Boolean
> true/false vs. a simple number.)
Nope. The above examples should disabuse your mind of that fundamentally flawed
concept.
The #switch() value isn't the thing that's the Boolean value.
The _result of the comparison_ of the #case() with the #switch() IS.
> Regarding (C), I was under the impression from some earlier comments that
> #switch could use ANY positive/negative value to mean 'true' or (1)-- but that
> doesn't seem to be a correct interpretation. It seems that only #switch(1)
> works.
I think what was trying to be expressed, was that only zero is interpreted as
Boolean false in SDL, whereas any non-zero value is then by default interpreted
as true, since they're all non-zero.
> If I could just get past *these* misunderstandings, my world would be a MUCH
> happier place to be in ;-)
I hope you're happy.
:P
;)
Post a reply to this message
|
|