RE: Case-sensitive Struct keys
-Original Message- From: Cedric Villat [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 22, 2005 10:50 PM To: CF-Talk Subject: Re: Case-sensitive Struct keys Dave, Any ideas on how to do this? The reason I originally did it in a struct, was I could simply find the properties of a word, since it was the key. If I organize the data as an array of structs and have the word value be a key in my struct, wouldn't that require more overhead when searching for that word? Do you have any code that would quickly find a word if this was the case? Personally I would use structs for this... the words really aren't variable names rather their labels for variable data (perhaps a subtle rationalization, but it works for me). To maintain case sensitivity you'll just have to use array notation to set and get your key names. But in this case I think that structs are the way to go. I think we already covered this -- but array notation won't work for him to maintain the case-sensitivity because in his case the same word would be used twice with different case and actually need to have both instances of the word (because he's wieghting them for the probability of being SPAM). So array notation won't let him use both words -- it'd have to be a Java HashMap or he'd have to hash() them in the structure. Personally I'd probably use the HashMap. s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/story/?storyid=44477DE=1 http://www.sys-con.com/story/?storyid=45569DE=1 http://www.fusiontap.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:196096 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Case-sensitive Struct keys
Dave, Any ideas on how to do this? The reason I originally did it in a struct, was I could simply find the properties of a word, since it was the key. If I organize the data as an array of structs and have the word value be a key in my struct, wouldn't that require more overhead when searching for that word? Do you have any code that would quickly find a word if this was the case? Cedric The probabilities the words free and FREE would be different. But when I stick them in a structure, the values get overwritten. Perhaps you should use a different model for your data. As you say, free and FREE are values. I would recommend organizing your data in such a way that you use them as values rather than as variable names. 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! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:196043 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
-Original Message- From: Cedric Villat [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 22, 2005 10:50 PM To: CF-Talk Subject: Re: Case-sensitive Struct keys Dave, Any ideas on how to do this? The reason I originally did it in a struct, was I could simply find the properties of a word, since it was the key. If I organize the data as an array of structs and have the word value be a key in my struct, wouldn't that require more overhead when searching for that word? Do you have any code that would quickly find a word if this was the case? Personally I would use structs for this... the words really aren't variable names rather their labels for variable data (perhaps a subtle rationalization, but it works for me). To maintain case sensitivity you'll just have to use array notation to set and get your key names. But in this case I think that structs are the way to go. Jim Davis ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:196046 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
So I guess CF doesn't support case-sensitive keys in a structure. For example, given the following code: test = StructNew(); test.a = 5; test.A = 10; I would have hoped that 2 keys would have been made, a and A, but instead only 1 key is made, and has a value of 10. Is there anyway to have CF use case-sensitive keys so that I could do something like the above to get 2 keys? You can have CF remember the case of your key names using array notation: cfset test[a] = whatever However, if I recall correctly, these keys aren't really case-sensitive, in that test[A] would overwrite an existing test[a]. 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! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195835 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Case-sensitive Struct keys
Doesn't this also depend on what version of CF you are using? Pretty sure I got bit in the button this one either when going from CF4.5 to CF5 or CF5 to CFMX, I believe it was the latter. I was doing something like struct.q3 and then looking for that but it started bombing out after the upgrade. I'd have to dig up the exact file to be more specific though. On Mon, 21 Feb 2005 19:44:09 -0500, Dave Watts [EMAIL PROTECTED] wrote: So I guess CF doesn't support case-sensitive keys in a structure. For example, given the following code: test = StructNew(); test.a = 5; test.A = 10; I would have hoped that 2 keys would have been made, a and A, but instead only 1 key is made, and has a value of 10. Is there anyway to have CF use case-sensitive keys so that I could do something like the above to get 2 keys? You can have CF remember the case of your key names using array notation: cfset test[a] = whatever However, if I recall correctly, these keys aren't really case-sensitive, in that test[A] would overwrite an existing test[a]. 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! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195837 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Case-sensitive Struct keys
Cedric -- As you said, CF structures don't support case-sensitive keynames. Alternatives might include representing the structure as a case-sensitive XML document object or, if your structure keynames will never be anything other than the single characters you showed in your example, you could use test[asc(keyname)] = value; Thus, test.a would become test[asc('a')] and test.A would become test[asc('A')], clearly two different keys. If the keynames might be longer than a single character, one could imagine many other schemes that would hash, or map, the keynames into unique values to be used as substitute keynames. For example, each character in the keyname could be replaced by its asc() code translated to a 4-digit hexadecimal string. (I guess 4 hex digits are needed now (instead of the 2 digits that would have sufficed in the pre-Unicode era) since the Java UCS-2 character set used by CF gives values for asc() up to 65535.) Another example would be to maintain the set of keynames as a simple CF list and then use the position of the keyname in the list as the substitute keyname in the structure. One would just have to be careful to search the list with ListFind() instead of ListFindNoCase(). -- Larry Afrin Medical University of South Carolina Cedric Villat wrote: So I guess CF doesn't support case-sensitive keys in a structure. For example, given the following code: test = StructNew(); test.a = 5; test.A = 10; I would have hoped that 2 keys would have been made, a and A, but instead only 1 key is made, and has a value of 10. Is there anyway to have CF use case-sensitive keys so that I could do something like the above to get 2 keys? Thanks, Cedric ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195838 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Case-sensitive Struct keys
Cedric -- As you said, CF structures don't support case-sensitive keynames. Alternatives might include representing the structure as a case-sensitive XML document object or, if your structure keynames will never be anything other than the single characters you showed in your example, you could use test[asc(keyname)] = value; Thus, test.a would become test[asc('a')] and test.A would become test[asc('A')], clearly two different keys. Hash would work the same way for multi-character keys btw... test[hash(keyname)] = value; Of course that means you have to use hash to get the values back out also. s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/story/?storyid=44477DE=1 http://www.sys-con.com/story/?storyid=45569DE=1 http://www.fusiontap.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195841 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Case-sensitive Struct keys
Doesn't this also depend on what version of CF you are using? Pretty sure I got bit in the button this one either when going from CF4.5 to CF5 or CF5 to CFMX, I believe it was the latter. I was doing something like struct.q3 and then looking for that but it started bombing out after the upgrade. I'd have to dig up the exact file to be more specific though. CFMX will preserve the case of the key if the key is created using array notation, i.e. cfscript st = structnew(); st[hOmE] = home; st.aBoUt = about; writeoutput(structkeylist(st)); /cfscript This is not the same as case-sensitivity although it can cause problems in some cases if other code depends on the original behavior of structure keys being stored (or returned) as upper-case values. cfscript st = structnew(); st[hOmE] = home; st.home = home; writeoutput(structkeylist(st)); /cfscript I don't know if this will change the case of the key, but it won't produce a 2nd key. s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/story/?storyid=44477DE=1 http://www.sys-con.com/story/?storyid=45569DE=1 http://www.fusiontap.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195843 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
From: Cedric Villat [mailto:[EMAIL PROTECTED] So I guess CF doesn't support case-sensitive keys in a structure. For example, given the following code: test = StructNew(); test.a = 5; test.A = 10; I would have hoped that 2 keys would have been made, a and A, but instead only 1 key is made, and has a value of 10. Is there anyway to have CF use case-sensitive keys so that I could do something like the above to get 2 keys? Why would you want to do this? Keys/Variables with varying names only by case is NOT a good idea regardless of language. Even though CF doesn't mind, other languages do, especially Java! Build good habits now to avoid problems down the road should you venture into other languages. Also, varying case variables makes code cumbersome to read! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195844 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
From: Cedric Villat [mailto:[EMAIL PROTECTED] So I guess CF doesn't support case-sensitive keys in a structure. For example, given the following code: test = StructNew(); test.a = 5; test.A = 10; I would have hoped that 2 keys would have been made, a and A, but instead only 1 key is made, and has a value of 10. Is there anyway to have CF use case-sensitive keys so that I could do something like the above to get 2 keys? Why would you want to do this? Keys/Variables with varying names only by case is NOT a good idea regardless of language. Even though CF doesn't mind, other languages do, especially Java! Build good habits now to avoid problems down the road should you venture into other languages. Also, varying case variables makes code cumbersome to read! I suspect the intention is to actually manage case-sensitive user-input ... i.e. a user entered a and then entered A and _expected_ them to be separate items. s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/story/?storyid=44477DE=1 http://www.sys-con.com/story/?storyid=45569DE=1 http://www.fusiontap.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195846 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
You can use Java HashMaps to create your own case-sensitive struct. Try this: cfobject type=java action=create class=java.util.HashMap name=myStruct cfset myStruct.put( a, 5 ) cfset myStruct.put( A, 10 ) cfoutput a = #myStruct.get( a )#br A = #myStruct.get( A )# /cfoutput Here's the API reference for java.util.HashMap: http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html Vince Bonfanti New Atlanta Communications, LLC http://www.newatlanta.com -Original Message- From: Cedric Villat [mailto:[EMAIL PROTECTED] Sent: Monday, February 21, 2005 7:14 PM To: CF-Talk Subject: Case-sensitive Struct keys So I guess CF doesn't support case-sensitive keys in a structure. For example, given the following code: test = StructNew(); test.a = 5; test.A = 10; I would have hoped that 2 keys would have been made, a and A, but instead only 1 key is made, and has a value of 10. Is there anyway to have CF use case-sensitive keys so that I could do something like the above to get 2 keys? Thanks, Cedric ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195855 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
Doesn't this also depend on what version of CF you are using? I'm pretty sure that behavior has been the same since CF 4.5.1. 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! ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195866 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
Maintaining case with array notation? I was pretty sure that happened in 6.0. Doesn't this also depend on what version of CF you are using? I'm pretty sure that behavior has been the same since CF 4.5.1. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/story/?storyid=44477DE=1 http://www.sys-con.com/story/?storyid=45569DE=1 http://www.fusiontap.com ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195868 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
From: Dave Watts [mailto:[EMAIL PROTECTED] Sent: Monday, February 21, 2005 11:23 PM To: CF-Talk Subject: RE: Case-sensitive Struct keys Doesn't this also depend on what version of CF you are using? I'm pretty sure that behavior has been the same since CF 4.5.1. I'm nearly positive that it was, but I can check tomorrow (we still use CF 4.5 at the office). Just to stick in an unasked-for plug this and many other possibly little known aspects of CF are detailed in my guide to variables here (watch the wrap): http://www.depressedpress.com/depressedpress/Content/Development/ColdFusion/ Guides/Variables/Index.cfm Jim Davis ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195870 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Case-sensitive Struct keys
Michael, The reason for this is because I am implementing a Bayesian filter CFC. In doing so, I create a hash-table of words and their probability of spam. The probabilities the words free and FREE would be different. But when I stick them in a structure, the values get overwritten. Vince's hashtable is really what I'm after. I guess either I can use the java hashtable as the solution, or do as Issac suggested and hash() the key names myself. Cedric From: Cedric Villat [mailto:[EMAIL PROTECTED] Why would you want to do this? Keys/Variables with varying names only by case is NOT a good idea regardless of language. Even though CF doesn't mind, other languages do, especially Java! Build good habits now to avoid problems down the road should you venture into other languages. Also, varying case variables makes code cumbersome to read! ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195873 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Case-sensitive Struct keys
The probabilities the words free and FREE would be different. But when I stick them in a structure, the values get overwritten. Perhaps you should use a different model for your data. As you say, free and FREE are values. I would recommend organizing your data in such a way that you use them as values rather than as variable names. 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! ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195878 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54