Ordered Argument names
Does anyone know how to make CF provide a list of the names of Arguments in the order provided and without using cfargument tag? StructKeyList/StructKeyArray returns an arbitrary order in CF8, and a random order every time in CF7. Using Array functions on the Arguments scope results in a random order every time in CF7 and CF8. Run this code in CF to see the problem: Both Railo and BlueDragon return the expected order, which makes it very irritating that CF doesn't. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313140 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Ordered Argument names
>Does anyone know how to make CF provide a list of the names of Arguments in >the order provided and without using cfargument tag? > >StructKeyList/StructKeyArray returns an arbitrary order in CF8, and a >random order every time in CF7. > >Using Array functions on the Arguments scope results in a random order >every time in CF7 and CF8. > > >Run this code in CF to see the problem: > > > > > > > > > > > > You should be able to loop through the arguments array: -Dan ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313141 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Ordered Argument names
using your code on CF8 (8,0,0,176276), i get the structs returned in the same order (alpha by key name) each time. neither arbitrary nor random. i understand this isn't necessarily what you want... but it does seem to be consistent (for whatever that's worth). On Fri, Sep 26, 2008 at 12:21 PM, Peter Boughton <[EMAIL PROTECTED]>wrote: > Does anyone know how to make CF provide a list of the names of Arguments in > the order provided and without using cfargument tag? > > StructKeyList/StructKeyArray returns an arbitrary order in CF8, and a > random order every time in CF7. > > Using Array functions on the Arguments scope results in a random order > every time in CF7 and CF8. > > > Run this code in CF to see the problem: > > > > > > > > > > > > > > > Both Railo and BlueDragon return the expected order, which makes it very > irritating that CF doesn't. > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313142 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Ordered Argument names
>using your code on CF8 (8,0,0,176276), i get the structs returned in the >same order (alpha by key name) each time. neither arbitrary nor random. With 8,0,1,195765 I get a different order each time. Unless I drop the argument names. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313144 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Ordered Argument names
>using your code on CF8 (8,0,0,176276), i get the structs returned in the >same order (alpha by key name) each time. Odd. I'm on 8,0,1,195765 and it's definitely not alphabetic. For first, second and fourth I get "c,a,b", "y,z,x" and "d,f,b" Oddly, the third one switches between "y,a,b,x" or "y,b,a,x" or "y,x,a,b". ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313146 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Ordered Argument names
Here try this. Notice the cfset in the cffunction. -Chuck ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313147 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Ordered Argument names
On Fri, Sep 26, 2008 at 12:52 PM, C S <[EMAIL PROTECTED]> wrote: > >using your code on CF8 (8,0,0,176276), i get the structs returned in the > >same order (alpha by key name) each time. neither arbitrary nor random. > > With 8,0,1,195765 I get a different order each time. Unless I drop the > argument names. > > > That's pretty funky (the difference in behavior between hotfixes). Altho i don't believe structs are inherently meant to be 'ordered'. I suppose you could maintain that same behavior between fixes by doing an arraySort() on a structKeyArray() none of which really addresses the original poster's concern, however :\ -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313148 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Ordered Argument names
>You should be able to loop through the arguments array: > > > > > > > Nope, that gives values not names (assuming 1 -> i) Also, it doesn't come out in the same order each time. It *should* since arrays are supposed to be ordered, but in my version of CF the values are switching around each refresh. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313149 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Ordered Argument names
>>You should be able to loop through the arguments array: >> >> >> >> >> >> >> > >Nope, that gives values not names (assuming 1 -> i) > >Also, it doesn't come out in the same order each time. > >It *should* since arrays are supposed to be ordered, but in my version of >CF the values are switching around each refresh. Structures have no explicit order--so you can't expect them to come back in any specific order. Why do you need the keys to be in order anyway? -Dan ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313151 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Ordered Argument names
>That's pretty funky (the difference in behavior between hotfixes). Altho i >don't believe structs are inherently meant to be 'ordered'. Yes, that is my understanding too. Interesting that it does seem to return the correct order if you do not use named arguments. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313152 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Ordered Argument names
@Dan - Good question. If you are sending the argument name in the call to the cffunction then they can be in any order and the cffunction will figure it out. -Chuck ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313153 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Ordered Argument names
> >don't believe structs are inherently meant to be 'ordered'. > > Yes, that is my understanding too. Interesting that it does seem to > return the correct order if you do not use named arguments. Well it has to really - unnamed arguments in a random order would be impossible to use. But it'd be handy if they made named arguments work in the right order too. My understanding of the Arguments scope is(/was) that it's a special construct that inherits functionality of Structs and Arrays, but isn't actually either of them. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313159 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Ordered Argument names
On Fri, Sep 26, 2008 at 2:08 PM, Peter Boughton <[EMAIL PROTECTED]> wrote: > > >don't believe structs are inherently meant to be 'ordered'. > > > > Yes, that is my understanding too. Interesting that it does seem to > > return the correct order if you do not use named arguments. > > Well it has to really - unnamed arguments in a random order would be > impossible to use. > But it'd be handy if they made named arguments work in the right order too. > i think this was already asked (forgive me if i missed the answer. it's friday and i'm tired :))... but if the arguments are named, why does the order matter? -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313161 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Ordered Argument names
> Well it has to really - unnamed arguments in a random order would be > impossible to use. > But it'd be handy if they made named arguments work in the right order > too. {Smack} Of course the reason it works has nothing to do with arguments object itself. Talk about "Friday density" ;-) > My understanding of the Arguments scope is(/was) that it's a special > construct that inherits functionality of Structs and Arrays, but isn't > actually either of them. Yes, it is not. I believe it is an internal class that implements from java.util.Map. Now if it was an ordered collection, that would be sweet. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313167 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Ordered Argument names
> but if the arguments are named, why does the order matter? Ordinarily, over 99% of the time, it wouldn't. But I have a function which is called like this: doStuff( a:data , x:data ) doStuff( b:data , x:data ) doStuff( c:data , x:data ) doStuff( x:data ) So being able to determine the first arg name would be useful. The workaround I currently have gets the arg list then replaces out X, unless it's the only argument. And that only works because there's never more than two args in any one call... if there were more I'd probably have to resort to providing a separate list of arguments, and I don't like repeating myself. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313182 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Ordered Argument names
> So being able to determine the first arg name would be useful. Structures are unordered. If you want an ordered container, consider using an array. Alternatively, you could, of course, simply sort the keys alphabetically after retrieving them, if all you need is consistency. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313183 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4