Close Stack Cleanup

Tore Nilsen tore.nilsen at me.com
Thu Feb 4 17:27:27 EST 2021


I follow a similar approach to what Curry describes here, keeping it modular, but I do not do any clean up at closing time. Instead I execute the necessary routines as part of a preOpenStack handler. I then do not have to consider which way the stack was closed. This is also what I encourage my students to do, in order to present the users with a pristine application every time the user starts the application.

By keeping it modular, the clean up script can also be started from other handlers if necessary. 

Best regards
Tore Nilsen

> 4. feb. 2021 kl. 22:23 skrev Curry Kenworthy via use-livecode <use-livecode at lists.runrev.com>:
> 
> 
> Bob:
> 
> > I am trying to clean up my stack (i.e. clear the fields),
> > then save it when I close it
> 
> This is a good topic for LiveCode learners; I'm chiming in....
> 
> I often do something similar - but with an important difference:
> I perform cleanup when I save. I do NOT force an auto save.
> (More on that later.)
> 
> > BY ANY MEANS. That means by script, by menu OR by clicking the red dot
> > (of for WIN users the red X) in the title bar.
> > I need this to work in the IDE as well as in standalone.
> 
> So, let's halt at this point and take inventory of your desires!
> You want to trap at least 3 methods of initiating a close action.
> (Tally: 3)
> 
> Furthermore, IDE versus Standalone is an extra complexity.
> I don't like that, but it is the unfortunate reality.
> So I'm accounting for that extra complexity via a "+" designation!
> (Tally: "3+")
> 
> Now jumping ahead a bit to make a connection:
> 
> > If I use “CloseStack” instead
> 
> Remember our tally of "3+" Actions?
> The word "instead" suggests you're assuming a SINGLE trap.
> 
> Everyone here should know my KISS philosophy: less is better.
> 3 birds with one stone is superior; I'm always harping on that.
> But then again, in this case you have 3+ birds! :)
> 
> I'd hazard a guess on 2 traps - that's my experience for similar cases.
> (But if one will work, use one.)
> 
> > You would think closeStackRequest gets sent when I
> > click the red dot or X. You would be mistaken.
> 
> Actually I would NOT be mistaken, as long as we're talking about the X,
> and the stack has been named/saved at least once. Just tested it!
> 
> But among the "extra complexity" I mentioned, if the stack is dirty,
> the IDE will trap the close action at the front, BEFORE you get it.
> It can still fire, but AFTER you dance around a bit with the IDE.
> (Important to note that's the IDE; closeStackRequest does respond.)
> 
> To succeed in the IDE, you may indeed need to use closeStack.
> But that's probably "with" not "instead" of closeStackRequest!
> 
> We can still follow KISS and avoid duplicating code,
> via modularity - the 2 traps can call a common set of code.
> Using params or other means to handle the differences in the 2/3 cases.
> 
> > I just want it to be saved. I can force quit if I mess something up.
> 
> I DISCOURAGE using a custom auto-save and resorting to force quit.
> If you implement an auto-save, do it very well.
> (And done well, a force-quit would not likely be Plan A for reverting.)
> 
> But I encourage cleanup when saving or when closing. I do it constantly.
> It just requires a set of trap(s) that does spring for the 3 actions.
> You're half way there, just think "AND" not "instead" to finish it!
> 
> Best wishes,
> 
> Curry Kenworthy
> 
> Custom Software Development
> "Better Methods, Better Results"
> LiveCode Training and Consulting
> http://livecodeconsulting.com/
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list