Here's your workaround.
1. Use a combination of arrays and structures instead of lists.
2. Use uncommon delimiters (like ^) to delimit fields and new lines to
delimit records.
So, a file might look like this:
-----[ begin locations.txt ]-----
Chicago^Illinois
Boise^Idaho
Los Angeles^California
Boston^Massachussetts
-----[ end locations.txt ]-----
To load stuff into an array of structures, try something like this:
<!--- read the file --->
<cffile action="read" file="c:\yourPathHere\locations.txt"
variable="strFileContent">
<!--- create a new array to hold the records --->
<cfset arrRecords = arrayNew(1)>
<!--- loop over each line of the file --->
<cfloop list="#strFileContent#" index="line"
delimiters="#chr(10)##chr(13)#">
<!--- if it's not empty --->
<cfif len(trim(line))>
<!--- trim it --->
<cfset line = trim(line)>
<!--- column 1 = city --->
<cfset strCity = listGetAt(line,1,"^")>
<!--- column 2 = state --->
<cfset strState = listGetAt(line,2,"^")>
<!--- add a new struct to the array for this record --->
<cfset intNextPosition = arrayLen(arrRecords) + 1>
<cfset arrRecords[intNextPosition] = structNew()>
<cfset arrRecords[intNextPosition].strCity = strCity>
<cfset arrRecords[intNextPosition].strState = strState>
</cfif>
</cfloop>
Then you could do something like this to loop through and output all the
records.
<cfloop from="1" to="#arrayLen(arrRecords)#" index="i">
<cfoutput>
City : #arrRecords[i].strCity#<br>
State : #arrRecords[i].strState#<br>
<br>
</cfoutput>
</cfloop>
No substitute for the delimiter problem, but a decent workaround... at least
in my opinion.
-Tyson
------------------------------------------------
Tyson Vanek, Technical Lead
duoDesign, The eBusiness Architects
Building your business online
847.491.3000 main | [EMAIL PROTECTED]
847.491.3100 fax | www.duodesign.com
847.491.4270 direct | www.chicagoangels.org
Come to our free 2-hour seminar "The eBusiness Squeeze"
http://www.duodesign.com/squeeze/seminar.html
-----Original Message-----
From: kaigler [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 22, 2001 11:31 AM
To: CF-Server
Subject: cfloop - limitation
Here is the example from allaire regarding cfloop:
<cfloop index = "ListElement"
list = "John/Paul,George::Ringo"
delimiters = ",:/">
<cfoutput>#ListElement#</cfoutput><BR>
</cfloop>
Delimiters can be specified in any order. Consecutive delimiters are
treated as a single delimiter; thus the two colons in the previous example
are treated as a single delimiter between "George" and "Ringo."
Is it just me or is the fact that consecutive delimiters are treated as a
single delimiter a major flaw?
Does anyone have a work around for this other thanscanning the file from
byte 1 to the last byte and manipulating the data so that is does not look
like consecutive delimiters?
kaigler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
------------------------------------------------------------------------------
To unsubscribe, send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body or visit the list page at www.houseoffusion.com