|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Compare digits as strings not integers
Author: Axel Schultze
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304411
Ian,
this may work for you.
Axel
<CFIF oldcompany IS newcompany AND LEN(oldcompany) IS LEN(newcompany)>
they are equal
<cfelse>
they are not equal
</CFIF>
><CFSET oldcompany = '033'>
><CFSET newcompany = '0033'>
>
>How would one compare these as strings and get a NOT equal result rather
>then integers resulting in an equal result?
Author: Axel Schultze
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304410
Ian,
this may work for you.
Axel
<CFIF oldcompany IS newcompany AND LEN(oldcompany) IS LEN(newcompany)>
they are equal
<cfelse>
they are not equal
</CFIF>
><CFSET oldcompany = '033'>
><CFSET newcompany = '0033'>
>
>How would one compare these as strings and get a NOT equal result rather
>then integers resulting in an equal result?
Author: Bobby Hartsfield
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304397
Well its ONE way... ;-)
.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
http://cf4em.com
Using compare() and compareNoCase() is really the right way. My only gripe
is that the returned value isn't very intuitive.
----- Excess quoted text cut - see Original Post for more -----
Author: Sonny Savage
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304390
Using compare() and compareNoCase() is really the right way. My only gripe
is that the returned value isn't very intuitive.
----- Excess quoted text cut - see Original Post for more -----
Author: Bobby Hartsfield
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304361
Just stick an alpha character in front of them when comparing or compare len
AND value.
.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
http://cf4em.com
<CFSET oldcompany = '033'>
<CFSET newcompany = '0033'>
How would one compare these as strings and get a NOT equal result rather
then integers resulting in an equal result?
Author: Ian Skinner
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304355
Dave Watts wrote:
----- Excess quoted text cut - see Original Post for more -----
I was considering that, but I felt sure there was a CF way to do this,
finally found the right documentation page compare().
<CFSET aVal = '033'>
<CFSET bVal = '0033'>
<cfoutput>
#aVal#:#bVal#
#aVal EQ bVal#
#aVal IS bVal#
#compare(aVal,bVal)#
</cfoutput>
Author: Claude Schneegans
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304354
Use the Compare() function, ie:
<CFSET oldcompany = '033'>
<CFSET newcompany = '0033'>
<CFOUTPUT>#(oldcompany EQ newcompany)#<BR>
#(Compare(oldcompany, newcompany) EQ 0)#
</CFOUTPUT>
--
_______________________________________
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: piegeacon@internetique.com)
Thanks.
Author: Dave Watts
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304353
> <CFSET oldcompany = '033'>
> <CFSET newcompany = '0033'>
>
> How would one compare these as strings and get a NOT equal
> result rather then integers resulting in an equal result?
You could tack a non-numeric value to the end of each, and compare the
resultant strings. There may be a better, and/or more elegant way, that's
just off the top of my head.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
Fig Leaf Training: Adobe/Google/Paperthin Certified Partners
http://training.figleaf.com/
WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers!
http://www.webmaniacsconference.com/
Author: Ian Skinner
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56203#304351
<CFSET oldcompany = '033'>
<CFSET newcompany = '0033'>
How would one compare these as strings and get a NOT equal result rather
then integers resulting in an equal result?
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||