|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Compare digits as strings not integers
<CFSET oldcompany = '033'>Ian Skinner 04/28/08 04:08 P Use the Compare() function, ie:Claude Schneegans 04/28/08 04:16 P Just stick an alpha character in front of them when comparing or compare lenBobby Hartsfield 04/28/08 05:57 P Using compare() and compareNoCase() is really the right way. My only gripeSonny Savage 04/29/08 08:11 A Well its ONE way... ;-)Bobby Hartsfield 04/29/08 09:40 A Ian,Axel Schultze 04/29/08 12:05 P Ian,Axel Schultze 04/29/08 12:06 P > <CFSET oldcompany = '033'>Dave Watts 04/28/08 04:11 P Dave Watts wrote:Ian Skinner 04/28/08 04:18 P <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? 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. 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? 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 ----- 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 ----- 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? 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? > <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/ 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>
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||