Unfortunately it's messy... 

<cfset numList = "1,2,5-9">
<cfset count = 0>
<cfloop list="#numList#" index="i">
        <cfif i CONTAINS "-">
                <cfset count = count + abs(val(i))>
        <cfelse>
                <cfset count = count + 1>
        </cfif>
</cfloop>

+-----------------------------------------------+
Bryan Love
  Macromedia Certified Professional
  Internet Application Developer
  Database Analyst
TeleCommunication Systems
[EMAIL PROTECTED]
+-----------------------------------------------+

"...'If there must be trouble, let it be in my day, that my child may have
peace'..."
        - Thomas Paine, The American Crisis

"Let's Roll"
        - Todd Beamer, Flight 93



-----Original Message-----
From: Tim Do [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 12:38 PM
To: CF-Talk
Subject: parsing user input to get count


I have a text field that I allow users to input data as follows:

1,2,5-9

Basically it is a coma delmited list with a range.  Whats the best way to
get a count... in this case I'd need to return 7

Thanks in advance...

______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to