Bruce, it's a fine example of a VBScript class, but the variables in a VBScript app get destroyed whether you have a terminate event for a class or not, which was David's original question.
Chip > -----Original Message----- > From: BT [mailto:bronx_...@fltg.net] > Sent: Sunday, June 17, 2012 8:33 AM > To: gw-scripting@gwmicro.com > Subject: Re: OnQuit > > > Hi David, > > Below is what I was referring to, Chip is partly correct, > but when a crash happens there is a call to the terminate > process done, and most classes, if not all of them have a > terminate process, which allows the interpreter to call that process. > > This is a simple class example you can study along with the > link for more > details: > Class TestClass > Private Sub Class_Initialize ' Setup Initialize event. > MsgBox("TestClass started") > End Sub > Private Sub Class_Terminate ' Setup Terminate event. > MsgBox("TestClass terminated") > End Sub > End Class > Set X = New TestClass ' Create an instance of TestClass. > Set X = Nothing ' Destroy the instance. > > Dave listen to what you get in both cases and you will get > the start and end message box of the class respectively in > this example. > > References: > http://msdn.microsoft.com/en-us/library/273zc69c(v=vs.85).aspx > Bruce > > Sent: Saturday, June 16, 2012 1:01 PM > Subject: RE: OnQuit > > > Hi David, > > Unfortunately Bruce's answer isn't applicable to VBScript; > we can only guess. My guess is that yes, the interpreter > does clear all memory used by an app when it closes. > > As for an event which executes when your app closes, there's > an event hidden away in the clientInFormation object named > onShutdown (it would be nice of the manual had a "see also" > section, and in this case if the onQuit event would reference > the onShutdown event; more than once I've wished for "see also" help). > > here's a little example: > > x=connectevent(clientinformation, "onShutdown", "onShutdown") > > sub onShutdown() > clipboard.appendText "onShutdown was called" > end sub > I don't believe you can do something such as put up a dialog > or open a message box in the onShutdown event, I believe WE > will soon kill your app and those will go away. > Don't forget, if you are covering all bases, you may need to > look into the onError event, which will fire if your app has > an error (in which case, I'm not sure if onShutdown will fire). > > hth, > > Chip > > ________________________________ > > From: David [mailto:eleph...@tele2.no] > Sent: Friday, June 15, 2012 7:07 PM > To: gw-scripting@gwmicro.com > Subject: OnQuit > > > > When connecting to the OnQuit Event, I do understand I can > create a sub, named things like OnQuit. Here, I could do a > bit of house cleaning for my app. But from what I can read in > the Reference manual, it seems this event only does fire when > WE as a total is closing down. Am I understanding it correct? > > If so, is there a way for me to do house cleaning, even if a > user turns off the app itself, but keeps WE running? Any > Event that fires, when an app is stopped or being disabled? > > Another techie thing: > Say my app is using 10Kb of memory for different objects and stuff. > I try to be in a habit of always setting objects that are not > in use to NOTHING. But imagine my app being poorly designed, > not doing this kind of nullifying. If now the user stop the > app - in the app manager - and then restart the app. Will the > app be using the SAME physical 10kb of memory, or will it > create allocations for new 10kb? I.e, if the app is stopped > and restarted 100 times, will it still only allocate the same > memory, or will there be a risk of memory usage building up? > Hope this makes sense. > > >