Re: StructClear and passing in a string...
This should work on CFMX AFAIK cfset StructClear( getPageContext().getBuiltinScopes().get( YOURSTRUCT ) ) / HTH On 1/26/07, Andy Matthews [EMAIL PROTECTED] wrote: I have an interesting situation... We have a multi-server configuration and there are times when we need to clear a certain structure, SESSION.userinformation or APPLICATION.siteinformation for example. BUT, we need to clear it across all servers. My first thought is to create a template that can be called on one server, which will cfhttp to the other servers and run this code: cfset StructClear(Evaluate(ARGUMENTS.myStruct)) Where myStruct is a URL variable passed into a CFC. Evaluate works, but I'm wondering if there's a way to avoid using it? Anyone have an idea? Andy Matthews Senior Coldfusion Developer Office: 877.707.5467 x747 Direct: 615.627.9747 Fax: 615.467.6249 [EMAIL PROTECTED] www.dealerskins.com http://www.dealerskins.com/ ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:267765 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: StructClear and passing in a string...
Interesting! I'll give that a shot, thank you Qasim! andy -Original Message- From: Qasim Rasheed [mailto:[EMAIL PROTECTED] Sent: Friday, January 26, 2007 1:47 PM To: CF-Talk Subject: Re: StructClear and passing in a string... This should work on CFMX AFAIK cfset StructClear( getPageContext().getBuiltinScopes().get( YOURSTRUCT ) ) / HTH On 1/26/07, Andy Matthews [EMAIL PROTECTED] wrote: I have an interesting situation... We have a multi-server configuration and there are times when we need to clear a certain structure, SESSION.userinformation or APPLICATION.siteinformation for example. BUT, we need to clear it across all servers. My first thought is to create a template that can be called on one server, which will cfhttp to the other servers and run this code: cfset StructClear(Evaluate(ARGUMENTS.myStruct)) Where myStruct is a URL variable passed into a CFC. Evaluate works, but I'm wondering if there's a way to avoid using it? Anyone have an idea? Andy Matthews Senior Coldfusion Developer Office: 877.707.5467 x747 Direct: 615.627.9747 Fax: 615.467.6249 [EMAIL PROTECTED] www.dealerskins.com http://www.dealerskins.com/ ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:267767 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: StructClear and passing in a string...
Quick question... What if we wanted to just call a CFC and pass in ANY scoped variable? -Original Message- From: Qasim Rasheed [mailto:[EMAIL PROTECTED] Sent: Friday, January 26, 2007 1:47 PM To: CF-Talk Subject: Re: StructClear and passing in a string... This should work on CFMX AFAIK cfset StructClear( getPageContext().getBuiltinScopes().get( YOURSTRUCT ) ) / HTH On 1/26/07, Andy Matthews [EMAIL PROTECTED] wrote: I have an interesting situation... We have a multi-server configuration and there are times when we need to clear a certain structure, SESSION.userinformation or APPLICATION.siteinformation for example. BUT, we need to clear it across all servers. My first thought is to create a template that can be called on one server, which will cfhttp to the other servers and run this code: cfset StructClear(Evaluate(ARGUMENTS.myStruct)) Where myStruct is a URL variable passed into a CFC. Evaluate works, but I'm wondering if there's a way to avoid using it? Anyone have an idea? Andy Matthews Senior Coldfusion Developer Office: 877.707.5467 x747 Direct: 615.627.9747 Fax: 615.467.6249 [EMAIL PROTECTED] www.dealerskins.com http://www.dealerskins.com/ ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:267769 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: StructClear and passing in a string...
From: Andy Matthews [mailto:[EMAIL PROTECTED] Quick question... What if we wanted to just call a CFC and pass in ANY scoped variable? Pass the name of the scope, that is, the string... session, application, etc.. and not the scope itself. ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:267771 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: StructClear(session)
On 4/8/02, sebastian palmigiani penned: After I do a StructClear(Session) the Session.URLToken that I have added to links also get cleared out and I get a message that Session.URLToken can't be found. How do I prevent it from doing it that? If you only have a couple session variables you could just delete them. cfscript structdelete(session, 'variable1'); structdelete(session, 'variable2'); /cfscript Otherwise, just make a local variables before you clear the session then reset the Session.URLToken. cfscript variables.URLToken = session.URLToken; structclear(session); session.URLToken = variables.URLToken; /cfscript Don't forget to lock either. :) -- Bud Schneehagen - Tropical Web Creations _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ColdFusion Solutions / eCommerce Development [EMAIL PROTECTED] http://www.twcreations.com/ 954.721.3452 __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: StructClear(session)
You can't if unless you move that variables content into another scope -Original Message- From: sebastian palmigiani [mailto:[EMAIL PROTECTED]] Sent: Monday, April 08, 2002 11:01 PM To: CF-Talk Subject: StructClear(session) After I do a StructClear(Session) the Session.URLToken that I have added to links also get cleared out and I get a message that Session.URLToken can't be found. How do I prevent it from doing it that? Thanks Sebastian __ 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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: StructClear(session) again...
Using StructClear(session) clears out the entire session scope, including sessionID, CFID CFTOKEN - if this is what you want, great. It's important to use StructClear(session.structName) if you want to clear only a single structure in the session scope. Chris Norloff -- Original Message -- from: Tage Widsell [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] date: Tue, 13 Nov 2001 11:03:05 +0100 Hi, Recently someone said that StructClear(session) was a bad way to remove session variables. Why? If I effectively want to remove an entire session (this is ti be used in a logout template), wouldn't StructClear(Session) be the way to do it? Regards Tage Widsell Webmaster Propellerhead Software ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: StructClear(session) again...
Tage, If you run a the StructClear() against the session scope you will lose ALL the session keys, including the session ID, CFID and CFTOKEN. Once these are gone, it is impossible to then associate a user with a session. Good luck, Beau -Original Message- From: Tage Widsell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 13, 2001 5:03 AM To: CF-Talk Subject: StructClear(session) again... Hi, Recently someone said that StructClear(session) was a bad way to remove session variables. Why? If I effectively want to remove an entire session (this is ti be used in a logout template), wouldn't StructClear(Session) be the way to do it? Regards Tage Widsell Webmaster Propellerhead Software ~~ 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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: StructClear(session) again...
structClear(session.loggedIn,username) would be a better alternative. Db - Original Message - From: Beau Harbin [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 5:00 AM Subject: RE: StructClear(session) again... Tage, If you run a the StructClear() against the session scope you will lose ALL the session keys, including the session ID, CFID and CFTOKEN. Once these are gone, it is impossible to then associate a user with a session. Good luck, Beau -Original Message- From: Tage Widsell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 13, 2001 5:03 AM To: CF-Talk Subject: StructClear(session) again... Hi, Recently someone said that StructClear(session) was a bad way to remove session variables. Why? If I effectively want to remove an entire session (this is ti be used in a logout template), wouldn't StructClear(Session) be the way to do it? Regards Tage Widsell Webmaster Propellerhead Software ~~ 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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: StructClear(session) again...
How is username defined here? The answer is probably obvious, but I'm still working on my first cup of coffee. - Matt Robertson [EMAIL PROTECTED] MSB Designs, Inc. http://mysecretbase.com - - Original Message - From: Douglas L. Brown [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 7:57 AM Subject: Re: StructClear(session) again... structClear(session.loggedIn,username) would be a better alternative. Db ~~ 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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: StructClear(session) again...
Well it depends on what the key is in your structure. I personally do not use a struct for keeping my login stuff, I just use the temp token etc. They will be independenat of eachother and will expire immediately once the user closes his browser. login page cfquery name=getLogin datasource=myDsn SELECT username,password FROM cust_login WHERE username = '#userName#' AND password = '#password#' /cfquery cfif getLogin.recordCount GT 0 cfset session.loggedIn = true cfelse cflocation url=/index.cfm?fuseaction=loginbadlogin=yes /cfif CFIF isDefined(session.loggedIn) CFSET session.loggedIn = false /CFIF - Original Message - From: Matt Robertson [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 9:58 AM Subject: Re: StructClear(session) again... How is username defined here? The answer is probably obvious, but I'm still working on my first cup of coffee. - Matt Robertson [EMAIL PROTECTED] MSB Designs, Inc. http://mysecretbase.com - - Original Message - From: Douglas L. Brown [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 7:57 AM Subject: Re: StructClear(session) again... structClear(session.loggedIn,username) would be a better alternative. Db ~~ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: StructClear(session) again...
DOH! I define the structure. duh. Thanks for the pointer ;D --Matt-- - Original Message - From: Douglas L. Brown [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 10:24 AM Subject: Re: StructClear(session) again... Well it depends on what the key is in your structure. I personally do not use a struct for keeping my login stuff, I just use the temp token etc. They will be independenat of eachother and will expire immediately once the user closes his browser. login page cfquery name=getLogin datasource=myDsn SELECT username,password FROM cust_login WHERE username = '#userName#' AND password = '#password#' /cfquery cfif getLogin.recordCount GT 0 cfset session.loggedIn = true cfelse cflocation url=/index.cfm?fuseaction=loginbadlogin=yes /cfif CFIF isDefined(session.loggedIn) CFSET session.loggedIn = false /CFIF - Original Message - From: Matt Robertson [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 9:58 AM Subject: Re: StructClear(session) again... How is username defined here? The answer is probably obvious, but I'm still working on my first cup of coffee. - Matt Robertson [EMAIL PROTECTED] MSB Designs, Inc. http://mysecretbase.com - - Original Message - From: Douglas L. Brown [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 7:57 AM Subject: Re: StructClear(session) again... structClear(session.loggedIn,username) would be a better alternative. Db ~~ 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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: StructClear(Session)
I actually just needed to delete a structure, so I read up a little and tried out some cfdumps, and according to Jedi Master Forta (Web Application Construction Kit, 4th Ed), StructClear just erases the current user's session (and everything in it.) It doesn't erase all session variables on the server, just the one's tied to that user's CFID and CFToken, which includes CDID, CFToken, SessionID, URLToken, and whatever variables your application uses... Tyler Silcox email | [EMAIL PROTECTED] website | www.gslsolutions.com - Original Message - From: Maia, Eric [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, November 13, 2001 2:31 PM Subject: StructClear(Session) Douglas said: One thing to note, is that with structClear() you will be killing all session vars and not just the user that logged out. I just checked, and in my app at least, this is not true. I use StructClear(session) to log folks out and it works just fine. I just tried logging in as two different users on two different machines, and I could log out one account and the other continued with no problems. I would think it would be a major inconsistency for it to clear all session variables for all sessions, since you can only set variables for the one active session. Here's the contents of my act_logout.cfm file: CFSET tmp = StructClear(Session) cfcookie name=cfid expires=NOW cfcookie name=cftoken expires=NOW - Eric ~~ 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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: StructClear(Session)
Douglas said: One thing to note, is that with structClear() you will be killing all session vars and not just the user that logged out. I just checked, and in my app at least, this is not true. I believe that it will not clear out the CFIF and CFToken in versions 4.x but will do so in version 5 So it depends on what version of CF you are using ~~ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: StructClear(Session)
Douglas said: One thing to note, is that with structClear() you will be killing all session vars and not just the user that logged out. I just checked, and in my app at least, this is not true. I believe that it will not clear out the CFIF and CFToken in versions 4.x but will do so in version 5 So it depends on what version of CF you are using I've just been told that it does this in CF 4.5 as well so I guess its versions prior to CF4.5 that are session safe. ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: StructClear
StructClear destroys struct keys. As for deleting structures altogether, I'm not sure. Surely there's got to be a way to unset variables, right? -- Jamie Keane Programmer SolutionMasters, Inc. 9111 Monroe Rd., Suite 100 Charlotte, NC 28270 www.solutionmasters.com 704.563.5559 x 228 Voice 704.849.9291 Fax -Original Message- From: Stas Newdel [EMAIL PROTECTED] To: CFTalk [EMAIL PROTECTED] Date: Friday, September 01, 2000 3:44 AM Subject: StructClear Does StructClear reset keys in a structure to be blank, or does it remove the keys? Also, what's a function to get rid of a structure altogether? Thank you --- --- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: StructClear
Stas- The StructClear() function completely empties a structure; keys and everything. Let's extend this for a second. Take the following situation: CFSET foo=StructNew() CFSET foo.bar=1 CFSET foo.quux=2 A structure with 2 keys, right? Now, you can clear this structure one of two ways: CFSET foo=StructNew()!--- just start over --- !--- or --- CFSET StructClear(foo)!--- just clear it out --- There is an important distinction, however. Remember that structures are passed (and assigned) by reference. So, let's assume that foo still has some data in it, and let's add the following scenario: CFSET brick=foo Now, whether you use StructClear() or StructNew() actually matters! This is because brick and foo now point to the *same data*. Not copies of the data, but the same data. To show this, you could now do: CFSET brick.bat=2 CFOUTPUT#foo.bat#/CFOUTPUT This is perfectly valid. So, as you can see, StructClear() and StructNew() will now do two very different things. If you use StructClear(): CFSET StructClear(foo) Then you are acting on the reference, you will therefore be clearing out the brick structure while you are at it: CFOUTPUT#StructCount(brick)#/CFOUTPUT !--- should show: 0 --- But, it we back up and use StructNew() instead: CFSET foo=StructNew() Then we are now simply overwriting foo's copy of the reference. So foo gets a new structure and brick stays intact: CFOUTPUT#StructCount(brick)#/CFOUTPUT !--- should show: 3 --- CFOUTPUT#StructCount(foo)#/CFOUTPUT !--- should show: 0 --- In this way, you can see that assigning to foo does not affect brick, but using functions that work on foo will affect brick (because the functions take a copy of the reference, while assigning overwrites the reference with a new one). So, to answer your second function, you can clear a structure any way you want: !--- does not affect brick --- CFSET foo="" CFSET brick="" !--- now the structure should be completely out of memory --- This distinction actually has several uses, but it's a bit tricky if you aren't wary of it. I've helped many a CF programmer who were tearing their hair out because they had used one instead of the other. :) HTH, Rick -Original Message- From: Stas Newdel [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 31, 2000 5:45 PM To: CFTalk Subject: StructClear Does StructClear reset keys in a structure to be blank, or does it remove the keys? Also, what's a function to get rid of a structure altogether? Thank you -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: StructClear
StructDelete(structure, key) :) If you wanted to clear the structe you COULD CFLOOP COLLECTION="structFoo" ITEM="i" CFSET StructDelete(structFoo, i) /CFLOOP And you are left with a mere shell of the structure you once had G :) Or you can use StructClear which clears out the *data* only. Jeremy -Original Message- From: Jamie Keane [mailto:[EMAIL PROTECTED]] Sent: Friday, September 01, 2000 11:02 AM To: [EMAIL PROTECTED] Subject: Re: StructClear StructClear destroys struct keys. As for deleting structures altogether, I'm not sure. Surely there's got to be a way to unset variables, right? -- Jamie Keane Programmer SolutionMasters, Inc. 9111 Monroe Rd., Suite 100 Charlotte, NC 28270 www.solutionmasters.com 704.563.5559 x 228 Voice 704.849.9291 Fax -Original Message- From: Stas Newdel [EMAIL PROTECTED] To: CFTalk [EMAIL PROTECTED] Date: Friday, September 01, 2000 3:44 AM Subject: StructClear Does StructClear reset keys in a structure to be blank, or does it remove the keys? Also, what's a function to get rid of a structure altogether? Thank you --- --- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: StructClear
Not quite true. Just ran a test and StructClear deletes the keys just like your loop does. Here is code you stick on any template to try: CFOUTPUT SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" CFSET myStruct = StructNew() CFSET myStruct.data = "somedata" alert("#IsDefined('myStruct.data')#"); CFSET StructClear(myStruct) alert("#IsDefined('myStruct.data')#"); /SCRIPT /CFOUTPUT I used js because I threw this in to a fusebox app I was working on and alerts don't mess up how the page looks. Justin Kidman -Original Message- From: Jeremy Allen [mailto:[EMAIL PROTECTED]] Sent: Friday, September 01, 2000 9:49 AM To: [EMAIL PROTECTED] Subject: RE: StructClear StructDelete(structure, key) :) If you wanted to clear the structe you COULD CFLOOP COLLECTION="structFoo" ITEM="i" CFSET StructDelete(structFoo, i) /CFLOOP And you are left with a mere shell of the structure you once had G :) Or you can use StructClear which clears out the *data* only. Jeremy -Original Message- From: Jamie Keane [mailto:[EMAIL PROTECTED]] Sent: Friday, September 01, 2000 11:02 AM To: [EMAIL PROTECTED] Subject: Re: StructClear StructClear destroys struct keys. As for deleting structures altogether, I'm not sure. Surely there's got to be a way to unset variables, right? -- Jamie Keane Programmer SolutionMasters, Inc. 9111 Monroe Rd., Suite 100 Charlotte, NC 28270 www.solutionmasters.com 704.563.5559 x 228 Voice 704.849.9291 Fax -Original Message- From: Stas Newdel [EMAIL PROTECTED] To: CFTalk [EMAIL PROTECTED] Date: Friday, September 01, 2000 3:44 AM Subject: StructClear Does StructClear reset keys in a structure to be blank, or does it remove the keys? Also, what's a function to get rid of a structure altogether? Thank you --- --- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: StructClear
Just as a cool point to bring up. This is what you would consider passing by reference. Since one object merely references something else and does nto actually copy the data and get its own set of data (passing by value). So, this opens up some interesting possibilities. Namely custom data structures among other things. I am kind of glad allaire did this however.. I do think it tends to confuse msot people since I cant think of any other data type in CF that behaves the way structures do. CF sucks with recursion still and I would be very afraid to use custom tags to manipulate a custom data structure built using this method.. (Such as a Stack of Queue) perhaps.. was there not a CFDJ article talking about this? I cant imagine this being overly useful to your average CF developer, But I guess in some cases this proves to be truly useful. Jeremy Allen [EMAIL PROTECTED] Insert Quarter Here [ ] -Original Message- From: Rick Osborne [mailto:[EMAIL PROTECTED]] Sent: Friday, September 01, 2000 12:56 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: StructClear Stas- The StructClear() function completely empties a structure; keys and everything. Let's extend this for a second. Take the following situation: CFSET foo=StructNew() CFSET foo.bar=1 CFSET foo.quux=2 A structure with 2 keys, right? Now, you can clear this structure one of two ways: CFSET foo=StructNew()!--- just start over --- !--- or --- CFSET StructClear(foo)!--- just clear it out --- There is an important distinction, however. Remember that structures are passed (and assigned) by reference. So, let's assume that foo still has some data in it, and let's add the following scenario: CFSET brick=foo Now, whether you use StructClear() or StructNew() actually matters! This is because brick and foo now point to the *same data*. Not copies of the data, but the same data. To show this, you could now do: CFSET brick.bat=2 CFOUTPUT#foo.bat#/CFOUTPUT This is perfectly valid. So, as you can see, StructClear() and StructNew() will now do two very different things. If you use StructClear(): CFSET StructClear(foo) Then you are acting on the reference, you will therefore be clearing out the brick structure while you are at it: CFOUTPUT#StructCount(brick)#/CFOUTPUT !--- should show: 0 --- But, it we back up and use StructNew() instead: CFSET foo=StructNew() Then we are now simply overwriting foo's copy of the reference. So foo gets a new structure and brick stays intact: CFOUTPUT#StructCount(brick)#/CFOUTPUT !--- should show: 3 --- CFOUTPUT#StructCount(foo)#/CFOUTPUT !--- should show: 0 --- In this way, you can see that assigning to foo does not affect brick, but using functions that work on foo will affect brick (because the functions take a copy of the reference, while assigning overwrites the reference with a new one). So, to answer your second function, you can clear a structure any way you want: !--- does not affect brick --- CFSET foo="" CFSET brick="" !--- now the structure should be completely out of memory --- This distinction actually has several uses, but it's a bit tricky if you aren't wary of it. I've helped many a CF programmer who were tearing their hair out because they had used one instead of the other. :) HTH, Rick -Original Message- From: Stas Newdel [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 31, 2000 5:45 PM To: CFTalk Subject: StructClear Does StructClear reset keys in a structure to be blank, or does it remove the keys? Also, what's a function to get rid of a structure altogether? Thank you -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: StructClear
StructDelete(structure, key) :) If you wanted to clear the structe you COULD CFLOOP COLLECTION="structFoo" ITEM="i" CFSET StructDelete(structFoo, i) /CFLOOP And you are left with a mere shell of the structure you once had G :) Or you can use StructClear which clears out the *data* only. Looping over the structure and deleting each member with StructDelete will be equivalent to using StructClear, which deletes all keys and values from within the structure. CF doesn't have a way of representing uninitialized variables - variables without values. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: StructClear
This is not true. :) The StructClear() function does the exact same thing your loop does - it completely empties the structure of both keys and values (data). Don't believe me? Try it: CFSET Bag=StructNew() CFLOOP FROM="1" TO="100" INDEX="i" CFSET Bag[i]=i /CFLOOP CFOUTPUTP#StructCount(Bag)#/P/CFOUTPUT CFSET StructClear(Bag) CFOUTPUTP#StructCount(Bag)#/P/CFOUTPUT You will get the following result: 100 0 -Rick -Original Message- From: Jeremy Allen [mailto:[EMAIL PROTECTED]] Sent: Friday, September 01, 2000 12:49 PM To: [EMAIL PROTECTED] Subject: RE: StructClear StructDelete(structure, key) :) If you wanted to clear the structe you COULD CFLOOP COLLECTION="structFoo" ITEM="i" CFSET StructDelete(structFoo, i) /CFLOOP And you are left with a mere shell of the structure you once had G :) Or you can use StructClear which clears out the *data* only. Jeremy -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: structclear
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --_=_NextPart_001_01BF9D84.2235BDF0 Content-Type: text/plain; charset="windows-1252" You mean it will clear client variables as well? I use that line of code for logout function. I think you were the person that also recommended that one put a cflock around tags that manipulate session variables...should it be done in this case as well? -Original Message- From: Raymond K. Camden [mailto:[EMAIL PROTECTED]] Sent: Monday, April 03, 2000 11:14 AM To: [EMAIL PROTECTED] Subject: RE: structclear It works, but too well. It also clears out session vars that ColdFusion uses to track you. You should either use StructDelete to remove individual variables, or simply store all of your stuff in a substructure, like Session.MyVars. Then you can call StructClear on that structure w/o any worries. === Raymond Camden, Webmaster of the Death Clock (www.deathclock.com) Cold Fusion Jedi Master for Syntegra (www.syntegra.com) Allaire Certified Instructor and Member of Team Allaire Email : [EMAIL PROTECTED] ICQ UIN : 3679482 "My ally is the Force, and a powerful ally it is." - Yoda -Original Message- From: Won Lee [mailto:[EMAIL PROTECTED]] Sent: Monday, April 03, 2000 9:51 AM To: cf-talk (E-mail) Subject: structclear I thought I had read that this line of code no longer works well in 4.5, is this true? cfset StructClear(session) Is there a better alternative? Should I be surrounding this with cflock? Won Lee Systems Consultant New Channel Technologies (330) 220-1558 [EMAIL PROTECTED] "Turning ideas into e-Business" allaire Premier Partner -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf _talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. --_=_NextPart_001_01BF9D84.2235BDF0 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: quoted-printable !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN" HTML HEAD META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dwindows-1252" META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2448.0" TITLERE: structclear/TITLE /HEAD BODY PFONT SIZE=3D2You mean it will clear client variables as = well?nbsp; I use that line of code for logout function.nbsp; /FONT /P PFONT SIZE=3D2I think you were the person that also recommended = that one put a lt;cflockgt; around tags that manipulate session = variables...should it be done in this case as well?/FONT/P PFONT SIZE=3D2-Original Message-/FONT BRFONT SIZE=3D2From: Raymond K. Camden [A = HREF=3D"mailto:[EMAIL PROTECTED]"mailto:raymond.k.camden@sy= ntegra.com/A]/FONT BRFONT SIZE=3D2Sent: Monday, April 03, 2000 11:14 AM/FONT BRFONT SIZE=3D2To: [EMAIL PROTECTED]/FONT BRFONT SIZE=3D2Subject: RE: structclear/FONT /P BR PFONT SIZE=3D2It works, but too well. It also clears out session = vars that ColdFusion uses/FONT BRFONT SIZE=3D2to track you. You should either use StructDelete to = remove individual/FONT BRFONT SIZE=3D2variables, or simply store all of your stuff in a = substructure, like/FONT BRFONT SIZE=3D2Session.MyVars. Then you can call StructClear on = that structure w/o any/FONT BRFONT SIZE=3D2worries./FONT /P PFONT = SIZE=3D2=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D/FONT= BRFONT SIZE=3D2Raymond Camden, Webmaster of the Death Clocknbsp; = (www.deathclock.com)/FONT BRFONT SIZE=3D2Cold Fusion Jedi Master for Syntegra = (www.syntegra.com)/FONT BRFONT SIZE=3D2Allaire Certified Instructor and Member of Team = Allaire/FONT /P PFONT SIZE=3D2Emailnbsp;nbsp; : [EMAIL PROTECTED]/FONT BRFONT SIZE=3D2ICQ UIN : 3679482/FONT /P PFONT SIZE=3D2quot;My ally is the Force, and a powerful ally it = is.quot; - Yoda/FONT /P BR PFONT SIZE=3D2gt; -Original Message-/FONT BRFONT SIZE=3D2gt; From: Won Lee [A = HREF=3D"mailto:[EMAIL PROTECTED]"mailto:[EMAIL PROTECTED]/= A]/FONT BRFONT SIZE=3D2gt; Sent: Monday, April 03, 2000 9:51 AM/FONT BRFONT SIZE=3D2gt; To: cf-talk (E-mail)/FONT BRFONT SIZE=3D2gt; Subject: structclear/FONT BRFONT SIZE=3D2gt;/FONT BRFONT SIZE=3D2gt;/FONT BRFO
RE: structclear
It will not clear client vars, that's a different scope. And yes, you should use CFLOCK in the case I described below. To be 100% safe, you should -always- use CFLOCK. === Raymond Camden, Webmaster of the Death Clock (www.deathclock.com) Cold Fusion Jedi Master for Syntegra (www.syntegra.com) Allaire Certified Instructor and Member of Team Allaire Email : [EMAIL PROTECTED] ICQ UIN : 3679482 "My ally is the Force, and a powerful ally it is." - Yoda -Original Message- From: Won Lee [mailto:[EMAIL PROTECTED]] Sent: Monday, April 03, 2000 11:49 AM To: '[EMAIL PROTECTED]' Subject: RE: structclear This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --_=_NextPart_001_01BF9D84.2235BDF0 Content-Type: text/plain; charset="windows-1252" You mean it will clear client variables as well? I use that line of code for logout function. I think you were the person that also recommended that one put a cflock around tags that manipulate session variables...should it be done in this case as well? -Original Message- From: Raymond K. Camden [mailto:[EMAIL PROTECTED]] Sent: Monday, April 03, 2000 11:14 AM To: [EMAIL PROTECTED] Subject: RE: structclear It works, but too well. It also clears out session vars that ColdFusion uses to track you. You should either use StructDelete to remove individual variables, or simply store all of your stuff in a substructure, like Session.MyVars. Then you can call StructClear on that structure w/o any worries. === Raymond Camden, Webmaster of the Death Clock (www.deathclock.com) Cold Fusion Jedi Master for Syntegra (www.syntegra.com) Allaire Certified Instructor and Member of Team Allaire Email : [EMAIL PROTECTED] ICQ UIN : 3679482 "My ally is the Force, and a powerful ally it is." - Yoda -Original Message- From: Won Lee [mailto:[EMAIL PROTECTED]] Sent: Monday, April 03, 2000 9:51 AM To: cf-talk (E-mail) Subject: structclear I thought I had read that this line of code no longer works well in 4.5, is this true? cfset StructClear(session) Is there a better alternative? Should I be surrounding this with cflock? Won Lee Systems Consultant New Channel Technologies (330) 220-1558 [EMAIL PROTECTED] "Turning ideas into e-Business" allaire Premier Partner -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf _talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- -- -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. --_=_NextPart_001_01BF9D84.2235BDF0 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: quoted-printable !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN" HTML HEAD META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dwindows-1252" META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2448.0" TITLERE: structclear/TITLE /HEAD BODY PFONT SIZE=3D2You mean it will clear client variables as = well?nbsp; I use that line of code for logout function.nbsp; /FONT /P PFONT SIZE=3D2I think you were the person that also recommended = that one put a lt;cflockgt; around tags that manipulate session = variables...should it be done in this case as well?/FONT/P PFONT SIZE=3D2-Original Message-/FONT BRFONT SIZE=3D2From: Raymond K. Camden [A = HREF=3D"mailto:[EMAIL PROTECTED]"mailto:raymond.k.camden@sy= ntegra.com/A]/FONT BRFONT SIZE=3D2Sent: Monday, April 03, 2000 11:14 AM/FONT BRFONT SIZE=3D2To: [EMAIL PROTECTED]/FONT BRFONT SIZE=3D2Subject: RE: structclear/FONT /P BR PFONT SIZE=3D2It works, but too well. It also clears out session = vars that ColdFusion uses/FONT BRFONT SIZE=3D2to track you. You should either use StructDelete to = remove individual/FONT BRFONT SIZE=3D2variables, or simply store all of your stuff in a = substructure, like/FONT BRFONT SIZE=3D2Session.MyVars. Then you can call StructClear on = that structure w/o any/FONT BRFONT SIZE=3D2worries./FONT /P PFONT = SIZE=3D2=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D/FONT= BRFO
RE: structclear
Could you enhance upon why you need to use cflock? Thanks! Any time you read or write to memory variables (session, application, server) you should use CFLOCK. If you're using CF 4.5, you should use the SCOPE attribute in your CFLOCK tag, otherwise use the NAME attribute. If you don't, you risk memory corruption issues, which you'll most likely see under heavy load. You might think that you don't have to lock accesses to session variables, especially reads of those variables, since sessions are associated with a single user. You'd be wrong. There are cases when multiple scripts may access the same session variables simultaneously, such as in a frameset, but also it seems that without explicitly locking the variables, even if they're not being accessed simultaneously, bad things may happen under heavy load. I don't know why that is, but I do know that you can prevent it by religiously using CFLOCK. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: structclear
Could you enhance upon why you need to use cflock? Thanks! I have forwarded to Michael a series of posts made to the Fusebox list some time ago about locking access to shared variable access. If anyone else is interested just let me know. You may also want to look at http://www.allaire.com/Handlers/index.cfm?ID=14165Method=Full Regards, Seth Petry-Johnson Argo Enterprise and Associates -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.