I am working on parsing a URL string and storing it in an array of structures.  I am 
to the point where it works to a certain extent, but not to the point where I need it. 
 To be more specific I am passing a string that should be parsed into two structure 
elements in the array.  The data seems to be inserted, but but when I try to access 
the structure key 'name' in array element 1 it comes up while array element 2 does 
not.  Here is the Query string that I am passing:

MaintenanceEditTable.cfm?table=tlkpStatus&tableCols=Statno, 
Status&ColOptions=name:Statno;width:100, name:Status;width:300

In this URL string I pass the database table name.  Then I pass table columns.  The I 
pass column options in the following format:
1. Comma delimits columns.
2. Semicolon delimits options for a column.
3. Colon delimits option / value pair.
4. Name option is required.  (Specifies name of column.)

Here is the code that parses ColOptions (note that cfoutput is only used to display 
debugging information):

<cfif isDefined("URL.ColOptions")>
        <!--- Parse out options and store in a structure. --->
        <cfset aColOpts = ArrayNew(1)>
        <cfset aColTemp = ArrayNew(1)>
        <cfset iCntLoop=1>
        <cfloop list="#URL.ColOptions#" index="Cols" delimiters=",">
                <cfset aColOpts[iCntLoop] = StructNew()>
                <cfloop list="#Cols#" index="Opts" delimiters=";">
                        <cfif #ListLen(Opts,":")# GT 1>
                                <cfset aColTemp[1] = #ListGetAt(Opts,1,":")#>
                                <cfset aColTemp[2] = #ListGetAt(Opts,2,":")#>
                                <!--- <cfoutput>#aColTemp[1]#, 
#aColTemp[2]#;</cfoutput> --->
                                <cfset Result = 
Evaluate("StructInsert(aColOpts[iCntLoop], '#aColTemp[1]#', '#aColTemp[2]#')")>
                                <cfoutput>#iCntLoop#, #aColTemp[1]#, 
#aColOpts[iCntLoop][aColTemp[1]]#; </cfoutput>
                        </cfif>
                </cfloop>
                <cfset iCntLoop=iCntLoop+1>
        </cfloop>
</cfif>

When I run this I interpreted the debugging information as meaning that values where 
entered and read back out of the first two positions in the array.  Please tell me if 
you have a different interpretation or find something wrong with mine.

Here is the code that ColdFusion choked on:

<cfloop FROM="1" TO="#ArrayLen(aColOpts)#" index="iCntDF">
        <cfoutput>#iCntDF#, #aColOpts[iCntDF].name#;</cfoutput>
</cfloop>

For me this seemed to go through the first position in the array and read the struct 
value, but it choked on the second position in the array.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to