No worries ;) Another useful feature of using array notation is that
you can have key names that are not valid variable names, ie. numbers.
Indeed, some clever clogs used this in a solution for getting x number
of random numbers that are all unique. It's posted in the archives
somewhere but it went something like this (paraphrased for example):
<cfscript>
function getRandomNumbers(n, rangeLower, rangeUpper){
var stRand = StructNew();
while(StructCount(stRand) LT arguments.n){
stRand[ RandRange( arguments.rangeLower, arguments.rangeUpper) ] = "";
}
return StructKeyArray(stRandomNumbers);
}
</cfscript>
Dom
2008/11/19 Charlie Griefer <[EMAIL PROTECTED]>:
> Wow, nice. I didn't know that either. I thought the key names were always
> returned in uppercase. Thanks for posting it.
>
> On Wed, Nov 19, 2008 at 1:12 PM, Al Musella, DPM
> <[EMAIL PROTECTED]>wrote:
>
>> Thanks. I didn't know that.. to save everyone
>> else from having to run it, the output is:
>>
>> Struct 1 keys: FOO,BAR
>> Struct 2 keys: foo,bar
>>
>> At 02:02 PM 11/19/2008, you wrote:
>> >A little code for your reference on how CF deals with struct keys:
>> >
>> ><cfset myStruct = StructNew() />
>> ><cfset myStruct.foo = "bar" />
>> ><cfset myStruct.bar = "foo" />
>> >
>> ><cfset myStruct2 = StructNew() />
>> ><cfset myStruct2['foo'] = "bar" />
>> ><cfset myStruct2['bar'] = "foo" />
>> >
>> ><cfoutput>
>> > Struct 1 keys: #StructKeyList(myStruct)#<br />
>> > Struct 2 keys: #StructKeyList(myStruct2)#
>> ></cfoutput>
>> >
>> >Knowing the difference can save you when using structs with js and xml,
>> etc.
>> >
>> >HTH
>> >
>> >Dominic
>> >
>> >
>> >2008/11/19 Al Musella, DPM <[EMAIL PROTECTED]>:
>> > > That worked! Thanks
>> > >
>> > >
>> > >>JavaScript is case-sensitive. Structs are returned with key names in
>> > >>uppercase. Try result.CITY and result.STATE.
>> > >
>> > >
>> >
>> >
>>
>>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:315655
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4