My CFDumps seem to change order when I dump them out. I am surprised
that your CFDump outputs in a consistent order.

Instead of doing a collection loop, try doing a list loop over the
struct keys StructKeyList(), then using those keys to access the struct.
This might be more consistent. 


......................
Ben Nadel
Certified Advanced ColdFusion MX7 Developer
www.bennadel.com
 
Need ColdFusion Help?
www.bennadel.com/ask-ben/

-----Original Message-----
From: Tom King [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 08, 2007 10:26 AM
To: CF-Talk
Subject: Outputting structs

Hi All, 

i've created a struct which when outputted, outputs in the 'wrong order'
If you run the code below when you're in a subdirectory, i.e:

/home/mydir1/mydir2/somepage.cfm

each dir and page name is added to the struct in order:
When I dump the struct, it comes out in the correct order, but when I
loop it as a collection, it comes out in a wierd order?
I know that structs don't have exact row numbering, but can anyone tell
me why the dump order is different to the actual outputted order?

Thanks
T


<cfsilent>
        <cfscript>
                //Create a struct to play with
                Bread.struct=StructNew();
                //Set our root location
                currentlocale="/";
        </cfscript>
        
        <!---CGI.SCRIPT_NAME is the var with the current location in--->
        <cfloop list="#cgi.SCRIPT_NAME#" delimiters="/" index="i">
                <cfscript>
                        //Insert the looped value into the struct,
replacing underscores and .cfm
                        //The keyname becomes the URL, and the keyvalue
is the text to link
                        StructInsert(Bread.struct, "#currentLocale##i#",
"#replace(replace(i, '_', ' ', 'all'), '.cfm', '', 'all')#");
                        //Update currentlocale, which acts as the string
to update
                        currentlocale="#currentLocale##i#/";
                </cfscript>
        </cfloop>
</cfsilent>

<!---For demo purposes, dump the struct - note the order---> <cfdump
var="#bread#">

<!---Output the struct--->
<cfoutput>
        <div>
        <p>
                <cfloop collection="#bread.struct#" item="i">
                        <cfoutput>
                        <a href="#i#">#bread.struct[i]#</a> &gt;
                        </cfoutput>
                </cfloop>
        <p> 
        </div>
</cfoutput>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277278
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