Why not just use something like:

<cfset parsed = listlast(theArray[i].description.xmlText, " ")>
<cfif Len(parsed) GT 1>
        <cfset amount = Right(parsed, Len(parsed)-1>
<cfelse>
        <cfset amount = 0>
</cfif>

Untested... be warned. The only reason I left the dollar sign was to make
sure a result came back no matter what for the ListLast. There's probably a
better way of doing this though...

!k

-----Original Message-----
From: Che Vilnonis [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 05, 2008 2:59 PM
To: CF-Talk
Subject: String Manipulation Fun

Take the following xml string value:
        1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $44900

I use the following code to extract and set the price:

<cfif findNoCase("$", theArray[i].description.xmlText)>
        <cfset price = listlast(theArray[i].description.xmlText, "$")>
</cfif>

Sometimes though, the xml data is incomplete and looks like this:
        1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $

My current logic bombs on the listlast statement. Any ideas how to fail
gracefully and set the price to zero when this happens?

Thanks, Che




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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-Talk/message.cfm/messageid:298264
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to