|
|
clipka <ano### [at] anonymousorg> wrote:
>
> Also, there's a much easier way to achieve a logical OR in any `#switch`
> construct: Just place multiple `#case` statements without a `#break` in
> between, like so:
>
> #switch(0)
> #case(strcmp(STRING,CONST1A))
> #case(strcmp(STRING,CONST1B))
> // go here if STRING = CONST1A or CONST1B
> #break
> #case(strcmp(STRING,CONST2A))
> #case(strcmp(STRING,CONST2B))
> // otherwise go here if STRING = CONST2A or CONST2B
> #break
>
I didn't know that using #cases without #breaks was possible :-O Thanks! That's
the construction I will probably use; it's nice and elegant. In fact, so
interesting that a note in the documentation about it would be justified ;-)
BTW, I almost never use #switch(true) in my scenes, usually just #switch(1) or
#switch(0)-- believing that they are the 'logical equivalents' of true/false,
not just the 'number values' 1 and 0. It has always worked for me, but is my
assumption valid, in light of all that's been said?
Another question, just to clarify something: Is there a difference between the
following two examples? (I don't actually code the latter way-- it may not even
be appropriate-- but I've seen various types of non-strcmp() constructions in
the newsgroups that look similar)...
#switch(0)
#case(strcmp(IMG_TYPE,AA))
and
#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.
Post a reply to this message
|
|