> -----Original Message-----
> From: Ioannis Papanikolaou [mailto:[EMAIL PROTECTED]
> Sent: Saturday, March 15, 2008 5:14 PM
> To: CF-Community
> Subject: EQ OR
>
> Hello people,
>
> Quick one. :
>
> I am trying to do <cfif #arguments.argumentname# EQ "Text1">
> function..... </cfif>
> And it works perfectly. When I am trying to add more texts than I want
> this variable to be equall with like:
> <cfif #arguments.argumentname# EQ "Text1" OR "Text2"> function.....
> </cfif>
> then I have a is not.
This is a common assumption but it's wrong. Even a language as easy CF
doesn't always make grammatical sense. ;^)
In short the correct expression would be:
<cfif arguments.argumentname EQ "Text1" OR arguments.argumentname EQ
"Text2">
For a boolean expression each segment needs to resolve to a value, either
"true" or "false". A segment is either a single value that results in
"true" or "false" or two values separated by a operator ("OR", "AND", etc)
that result in those values.
The firstattempt doesn't: (arguments.argumentname EQ "Text1") resolves to a
value but ("Text1" OR "Text2") doesn't - it's nonsensical since it doesn't
result in "true" or "false" (or a value CF can convert to "true" or
"false").
However the second does: both (arguments.argumentname EQ "Text1") and
(arguments.argumentname EQ "Text2") resolve to "true" or "false".
Basically just break up your expressions - if any part makes no sense then
the whole thing makes no sense.
Now: there are two other things to think about:
1) You only need pounds signs ("#") in CF to mark variables inside strings.
So in this case you don't need them. Here's an example:
<cfif arguments.argumentname EQ "Text#Count#">
The first variable isn't inside a string, so it doesn't need them (using
them doesn't really hurt, but does clutter things up), but the second IS -
it needs them.
This is a rule of thumb - some tags get a little goofy with their
parameters. But for any expressions it's dogma.
2) CF provides useful functions to make this kind of thing easier. Look at
"ListFind()" (or "ListFindNoCase()"). For example, your original expression
could be condensed to this:
<cfif ListFind("Text1,Text2", arguments.argumentname)>
ListFind returns a zero (which CF automatically converts to "false" in
Boolean expressions) if the value isn't in the list, or a positive number
(which CF automatically converts to "true" in Boolean expressions) if it is
(the number is if the position of the value in the list).
Hope this helps,
Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:256511
Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5