Close Stack Cleanup

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Close Stack Cleanup

Mark Wieder via use-livecode
Hi all.

I know we have tread this ground before, but I am trying to clean up my stack (i.e. clear the fields), then save it when I close it 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.

You would think closeStackRequest gets sent when I click the red dot or X. You would be mistaken.

The dictionary reads,

The closeStackRequest message is only sent if the request to close a stack is initiated by the user (eg by clicking file -> close in the LiveCode menu). If the request is initiated from a script (eg "close this stack" ) then the closeStackRequest message is not sent.

Apparently clicking the red dot is not considered, “initiated by the user.” It ought to be.

If I use “CloseStack” instead, I cannot save the stack because a script is currently running, and I do not want to be presented with the dialog to save, do not save, or cancel. I just want it to be saved. I can force quit if I mess something up.

Bob S

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode

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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
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 <[hidden email]>:
>
>
> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
Thanks for the response Curry and Tore.

The reason I clean up at close is because when I open the stack the next time I do not want to remains of what I was doing before to show. It’s a small point but it look cleaner if the first time opening the stack there is nothing in the fields. All attempts to hide the stack then clear it before making it visible have been iffy.

I guess what I need is a message or series of messages that get generated BEFORE the stack is closed.

I have this in the only card in my stack:

on closeStackRequest
   resetMainForm
   save this stack
   pass closeStackRequest — this has a breakpoint
end closeStackRequest

I have a breakpoint on the pass statement. When clicking the red dot I get asked if I want to save the stack. For whatever reason, for me the closeStackRequest is NOT getting sent to the current card!

Bob S


> On Feb 4, 2021, at 1:23 PM, Curry Kenworthy via use-livecode <[hidden email]> wrote:
>
>
> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
Performing the clean up in preOpenStack makes it happen before the stack is visible, at least according to the dictionary.

"Unlike openStack <>, preOpenStack handlers <> are executed <> before the stack window <> appears. Because of this, the preOpenStack handler <> is a good place to put code that adjusts the size, position, and appearance of objects <>; the changes are made before the stack <> appears."

My experience is that this is true.


Tore

> 4. feb. 2021 kl. 23:43 skrev Bob Sneidar via use-livecode <[hidden email]>:
>
> Thanks for the response Curry and Tore.
>
> The reason I clean up at close is because when I open the stack the next time I do not want to remains of what I was doing before to show. It’s a small point but it look cleaner if the first time opening the stack there is nothing in the fields. All attempts to hide the stack then clear it before making it visible have been iffy.
>
> I guess what I need is a message or series of messages that get generated BEFORE the stack is closed.
>
> I have this in the only card in my stack:
>
> on closeStackRequest
>   resetMainForm
>   save this stack
>   pass closeStackRequest — this has a breakpoint
> end closeStackRequest
>
> I have a breakpoint on the pass statement. When clicking the red dot I get asked if I want to save the stack. For whatever reason, for me the closeStackRequest is NOT getting sent to the current card!
>
> Bob S
>
>
>> On Feb 4, 2021, at 1:23 PM, Curry Kenworthy via use-livecode <[hidden email]> wrote:
>>
>>
>> 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
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
There used to be a gREV* global variable that tracked the dirty status and if the stack was
dirty it put up the "do you want to save?" dialog. I can't find it now so something has
changed. When it existed, you could toggle that variable via script and the IDE wouldn't bother
you.

The IDE does pass the closeStackRequest to your stack after it checks the stack status. The
docs are correct that you don't get that message when a script closes the stack but you can use
closeStack instead; however, first we need to find out where that variable went to. It used to
be in the globals pane of the message watcher, and I'd recognize it if I saw it, but I can't
remember now what it was.

On 2/4/21 12:59 PM, Bob Sneidar via use-livecode wrote:

> Hi all.
>
> I know we have tread this ground before, but I am trying to clean up my stack (i.e. clear the fields), then save it when I close it 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.
>
> You would think closeStackRequest gets sent when I click the red dot or X. You would be mistaken.
>
> The dictionary reads,
>
> The closeStackRequest message is only sent if the request to close a stack is initiated by the user (eg by clicking file -> close in the LiveCode menu). If the request is initiated from a script (eg "close this stack" ) then the closeStackRequest message is not sent.
>
> Apparently clicking the red dot is not considered, “initiated by the user.” It ought to be.
>
> If I use “CloseStack” instead, I cannot save the stack because a script is currently running, and I do not want to be presented with the dialog to save, do not save, or cancel. I just want it to be saved. I can force quit if I mess something up.
>
> Bob S
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
Thanks for the reply Jacque. I ran the message watcher while clicking the red dot. None of the messages that appear have anything to do with closing the stack.

Here’s what I came up with. The closeStackRequest is NOT getting sent to the current card as the dictionary indicates, although the target IS the current card. It DOES get sent to the stack though. So I put this in the stack script and it DOES work with the red dot.

on closeStackRequest
   if the short name of the target is "Main” then — I have substacks but no other cards called Main
      dispatch resetMainForm to the target
   end if

   save this stack
   pass closeStackRequest
END closeStackRequest

Bob S


On Feb 4, 2021, at 2:52 PM, J. Landman Gay via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

There used to be a gREV* global variable that tracked the dirty status and if the stack was dirty it put up the "do you want to save?" dialog. I can't find it now so something has changed. When it existed, you could toggle that variable via script and the IDE wouldn't bother you.

The IDE does pass the closeStackRequest to your stack after it checks the stack status. The docs are correct that you don't get that message when a script closes the stack but you can use closeStack instead; however, first we need to find out where that variable went to. It used to be in the globals pane of the message watcher, and I'd recognize it if I saw it, but I can't remember now what it was.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
It’s my understanding that I am unable to reference objects on a card of a stack in a preOpenStack handler. Referencing an object in the stack opens the stack triggering a race condition which continually triggers preOpenStack. That is from memory though.

Bob S


On Feb 4, 2021, at 2:50 PM, Tore Nilsen via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Performing the clean up in preOpenStack makes it happen before the stack is visible, at least according to the dictionary.

"Unlike openStack <>, preOpenStack handlers <> are executed <> before the stack window <> appears. Because of this, the preOpenStack handler <> is a good place to put code that adjusts the size, position, and appearance of objects <>; the changes are made before the stack <> appears."

My experience is that this is true.


Tore

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode

Tore:

 > 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.

Yes! Like you, for cleanup I also avoid that how-closed consideration.
Much easier to have a simpler single trap.

Yet I ALSO avoid saving user/test data!
That keeps my files smaller in their saved state.

And if opened with messages off, still cleaner....

Bob:

 > when I open the stack the next time I do not want to
 > remains of what I was doing before to show.

You can! Several routes to choose. Presenting the easiest.

Me again:

 > I perform cleanup when I save.

In other words, try saveStackRequest!
Don't "save" with your own code; let LC IDE do that.
Just perform your cleanup, then pass.
That way your cleaned-up stack is reliably saved.

You get the best of both - simple trap, reliable.

(However, your original method would work - if you finish it!
And while typing this, I see you already made progress; that's good.)

Tore again:

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

Agreed!
Modularity increases performance, maintainability, and freedom.
Can't stress this enough.

Me again:

Don't think "clean up and save." Keep the twain separate.
I choose when to save, it's a conscious choice, and it fires my cleanup.
My stack is almost always saved clean.

Moreover I'm in the habit of saving (and backing up) BEFORE closing.
Habits are so important - they avoid needless suffering.

If I do forget my habit, the IDE will prompt me to save.
So I'm still OK - because I haven't disabled the system. It's my backup.
Nor do I rely primarily on that system. It's my backup. ;)

Best wishes,

Curry Kenworthy

Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
http://livecodeconsulting.com/

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
Thanks Curry. That works for the IDE, but not for the standalone. End Users do not save their stacks, as I give them no way to do so. The stacks in my app perform two functions: An interface to control the app and also a place to store persistent data i.e. properties. If a user force-quits my app for any reason, saving upon closing a sub stack ensures those updated properties are retained.

I could test for the IDE I know, but for my purposes, having lost so much form modifications in the past due to some kind of race condition or IDE lock up, I auto-save regularly, not just when I close a stack.

As an aside, this is what was slowing my Windows Standalones down so much. It has been well documented that the performance of saving a stack (especially one as complex as mine) in Windows is fairly oppressive. In a Windows Standalone I have to trap most of the times I save a stack, allowing only for saving upon close.

Bob S


On Feb 4, 2021, at 3:17 PM, Curry Kenworthy via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Me again:

Don't think "clean up and save." Keep the twain separate.
I choose when to save, it's a conscious choice, and it fires my cleanup.
My stack is almost always saved clean.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
<sigh> Back to the drawing board. This does NOT work when clicking the red dot.

Bob S


On Feb 4, 2021, at 3:10 PM, Bob Sneidar via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Thanks for the reply Jacque. I ran the message watcher while clicking the red dot. None of the messages that appear have anything to do with closing the stack.

Here’s what I came up with. The closeStackRequest is NOT getting sent to the current card as the dictionary indicates, although the target IS the current card. It DOES get sent to the stack though. So I put this in the stack script and it DOES work with the red dot.

on closeStackRequest
  if the short name of the target is "Main” then — I have substacks but no other cards called Main
     dispatch resetMainForm to the target
  end if

  save this stack
  pass closeStackRequest
END closeStackRequest

Bob S

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

RE: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
Is this what you're looking for?

revIDESetEdited pStackName
revIDESetUnedited pStackName

Interrogate it with: revIDEStackIsEdited pStackName

Ralph DiMola
IT Director
Evergreen Information Services
[hidden email]



-----Original Message-----
From: use-livecode [mailto:[hidden email]] On Behalf Of J. Landman Gay via use-livecode
Sent: Thursday, February 04, 2021 5:53 PM
To: How to use LiveCode
Cc: J. Landman Gay
Subject: Re: Close Stack Cleanup

There used to be a gREV* global variable that tracked the dirty status and if the stack was dirty it put up the "do you want to save?" dialog. I can't find it now so something has changed. When it existed, you could toggle that variable via script and the IDE wouldn't bother you.

The IDE does pass the closeStackRequest to your stack after it checks the stack status. The docs are correct that you don't get that message when a script closes the stack but you can use closeStack instead; however, first we need to find out where that variable went to. It used to be in the globals pane of the message watcher, and I'd recognize it if I saw it, but I can't remember now what it was.

On 2/4/21 12:59 PM, Bob Sneidar via use-livecode wrote:

> Hi all.
>
> I know we have tread this ground before, but I am trying to clean up my stack (i.e. clear the fields), then save it when I close it 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.
>
> You would think closeStackRequest gets sent when I click the red dot or X. You would be mistaken.
>
> The dictionary reads,
>
> The closeStackRequest message is only sent if the request to close a stack is initiated by the user (eg by clicking file -> close in the LiveCode menu). If the request is initiated from a script (eg "close this stack" ) then the closeStackRequest message is not sent.
>
> Apparently clicking the red dot is not considered, “initiated by the user.” It ought to be.
>
> If I use “CloseStack” instead, I cannot save the stack because a script is currently running, and I do not want to be presented with the dialog to save, do not save, or cancel. I just want it to be saved. I can force quit if I mess something up.
>
> Bob S
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
Thanks Ralph. Actually what I am looking for is a message that gets sent when the close button of a window gets clicked. The Message Watcher seems to indicate not (or rather fails to indicate). I think this is a bug, or at least an oversight. This means that anyone can close a stack, and closeStackRequest will not get triggered. This seems contrary to what closeStackRequest is for.

I will submit a feature request, but I suspect it’s going to be low on the totem pole.

Bob S


On Feb 4, 2021, at 3:53 PM, Ralph DiMola via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Is this what you're looking for?

revIDESetEdited pStackName
revIDESetUnedited pStackName

Interrogate it with: revIDEStackIsEdited pStackName

Ralph DiMola
IT Director
Evergreen Information Services
[hidden email]<mailto:[hidden email]>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
NVM I found this bug has already been submitted… IN 2008! LOL! https://quality.livecode.com/show_bug.cgi?id=4617 Hey Kevin! <poke>

Bob S


On Feb 4, 2021, at 4:05 PM, Bob Sneidar via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Thanks Ralph. Actually what I am looking for is a message that gets sent when the close button of a window gets clicked. The Message Watcher seems to indicate not (or rather fails to indicate). I think this is a bug, or at least an oversight. This means that anyone can close a stack, and closeStackRequest will not get triggered. This seems contrary to what closeStackRequest is for.

I will submit a feature request, but I suspect it’s going to be low on the totem pole.

Bob S

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
On 2/4/21 4:19 PM, Bob Sneidar via use-livecode wrote:
> NVM I found this bug has already been submitted… IN 2008! LOL! https://quality.livecode.com/show_bug.cgi?id=4617 Hey Kevin! <poke>

Looking at that, here's a (completely untested) suggestion:

The revIDEHandleCloseStackRequest handler is in the IDE backscript, so
it's ready to be overridden. If you don't override it then it executes a
revSaveCheck before moving on. If you override this command then you
might get what you want.

...at the risk of losing data...

so maybe in your stack script you have:
on revIDEHandleCloseStackRequest
   return "pass"
end revIDEHandleCloseStackRequest

That said, I agree with others that this isn't a Good Idea, and a
cleaning routine in preOpenStack would do the trick nicely.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

RE: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
That looks like it would work though it isn't the variable I remember.
Probably that's what changed. Nice sleuthing.

--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On February 4, 2021 5:52:14 PM Ralph DiMola via use-livecode
<[hidden email]> wrote:

> Is this what you're looking for?
>
> revIDESetEdited pStackName
> revIDESetUnedited pStackName
>
> Interrogate it with: revIDEStackIsEdited pStackName
>
> Ralph DiMola
> IT Director
> Evergreen Information Services
> [hidden email]
>
>
>
> -----Original Message-----
> From: use-livecode [mailto:[hidden email]] On Behalf
> Of J. Landman Gay via use-livecode
> Sent: Thursday, February 04, 2021 5:53 PM
> To: How to use LiveCode
> Cc: J. Landman Gay
> Subject: Re: Close Stack Cleanup
>
> There used to be a gREV* global variable that tracked the dirty status and
> if the stack was dirty it put up the "do you want to save?" dialog. I can't
> find it now so something has changed. When it existed, you could toggle
> that variable via script and the IDE wouldn't bother you.
>
> The IDE does pass the closeStackRequest to your stack after it checks the
> stack status. The docs are correct that you don't get that message when a
> script closes the stack but you can use closeStack instead; however, first
> we need to find out where that variable went to. It used to be in the
> globals pane of the message watcher, and I'd recognize it if I saw it, but
> I can't remember now what it was.
>
> On 2/4/21 12:59 PM, Bob Sneidar via use-livecode wrote:
>> Hi all.
>>
>> I know we have tread this ground before, but I am trying to clean up my
>> stack (i.e. clear the fields), then save it when I close it 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.
>>
>> You would think closeStackRequest gets sent when I click the red dot or X.
>> You would be mistaken.
>>
>> The dictionary reads,
>>
>> The closeStackRequest message is only sent if the request to close a stack
>> is initiated by the user (eg by clicking file -> close in the LiveCode
>> menu). If the request is initiated from a script (eg "close this stack" )
>> then the closeStackRequest message is not sent.
>>
>> Apparently clicking the red dot is not considered, “initiated by the user.”
>> It ought to be.
>>
>> If I use “CloseStack” instead, I cannot save the stack because a script is
>> currently running, and I do not want to be presented with the dialog to
>> save, do not save, or cancel. I just want it to be saved. I can force quit
>> if I mess something up.
>>
>> Bob S
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
I did a test before answering and the message was sent to the card of my
otherwise blank stack, after dismissing the IDE dialog. That makes me think
something is going on with your particular stack. What happens if you try
it with a plain new stack?

--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On February 4, 2021 6:07:32 PM Bob Sneidar via use-livecode
<[hidden email]> wrote:

> Thanks Ralph. Actually what I am looking for is a message that gets sent
> when the close button of a window gets clicked. The Message Watcher seems
> to indicate not (or rather fails to indicate). I think this is a bug, or at
> least an oversight. This means that anyone can close a stack, and
> closeStackRequest will not get triggered. This seems contrary to what
> closeStackRequest is for.
>
> I will submit a feature request, but I suspect it’s going to be low on the
> totem pole.
>
> Bob S
>
>
> On Feb 4, 2021, at 3:53 PM, Ralph DiMola via use-livecode
> <[hidden email]<mailto:[hidden email]>> wrote:
>
> Is this what you're looking for?
>
> revIDESetEdited pStackName
> revIDESetUnedited pStackName
>
> Interrogate it with: revIDEStackIsEdited pStackName
>
> Ralph DiMola
> IT Director
> Evergreen Information Services
> [hidden email]<mailto:[hidden email]>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode

Mark:
 > I agree with others that this isn't a Good Idea,
 > and a cleaning routine in preOpenStack would do the trick nicely.

Amen, Brother Mark! Good Idea to avoid Bad Habits.
(Agreed, except a small but crucial difference in details....)

As Tore said:
 > execute the necessary routines as part of a preOpenStack handler

Again, with a small but important difference:

The preOpenStack handler is NOT ideal for this type of cleanup.
"Literally, to "clear the fields" of a stack."
(And now we also know, a "complex" stack.)
That is NOT something best done in preOpenStack.

A complex stack usually has multiple cards.
The user is going from one card to the other - perhaps more than once.
You need this type of cleanup triggered by preOpenCard!
Whereas preOpenStack and startup are better for general init.
Keep it modular; preOpenCard and Clear Form can call the same code.

(You both already probably know that and do it.
Just making an explicit point for other readers who are learning.
People always tell me things they read here! They take it to heart.)

If you clean up fields in preOpenCard, you're ready for the end user.
But your saved stack may be very BLOATED at times!
Large amount data in a field, image, etc.

(And yes, in these days of interim-capacity SSDs, disk space matters.
Your stack will also be saved in a more cluttered state.)

To solve that easily, as I've said: use saveStackRequest!

That way your stack is SAVED clean and non-bloated.
You can freely test larger data samples.
Stacks are small for sharing within your dev team.

Your users will NEVER see your test data entries.
(Even if a preOpenX handler fails due to runtime bug,
which I've seen happen fairly often in stacks people make!
Potential embarrassments automatically averted.)
It's also perfect for simpler stacks with one card.

Bob:
 > Back to the drawing board.

Not if you take the advice of myself and others!
Proven solutions, well-tested over time, reliable, that work TODAY.
(But I do like the IDE bug report; the IDE tramples some messages.)
Good topic! People will learn from it. Thanks for starting it.

Best wishes,

Curry Kenworthy

Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
http://livecodeconsulting.com/

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
On 2/4/21 6:33 PM, Curry Kenworthy via use-livecode wrote:

> The preOpenStack handler is NOT ideal for this type of cleanup.
> "Literally, to "clear the fields" of a stack."
> (And now we also know, a "complex" stack.)
> That is NOT something best done in preOpenStack.
>
> A complex stack usually has multiple cards.
> The user is going from one card to the other - perhaps more than once.
> You need this type of cleanup triggered by preOpenCard!
> Whereas preOpenStack and startup are better for general init.
> Keep it modular; preOpenCard and Clear Form can call the same code.

Ah... quite right. I do stand corrected there.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Close Stack Cleanup

Mark Wieder via use-livecode
Thanks all for your suggestions. I will try various methods.

As to the propriety of certain methods, I suppose in answer to why do it that way, to quote another thread, “Because we can!” :-)

Bob S

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
12