Page 1 of 1
Auto save on close stack
Posted: Thu Aug 27, 2009 5:01 pm
by AlexAdams
How can I have a stack save itself everytime it closes without a user dialog? Is there a preCloseStack message or something similar?
Thanks,
Posted: Thu Aug 27, 2009 5:42 pm
by Klaus
Hi Alex,
omit the "pre" and you are done
Add these lines to your closestack handler, that will do the trick:
Code: Select all
on closestack
save this stack
end closestack
Best
Klaus
Save prompt comes before the closeStack message is sent
Posted: Thu Aug 27, 2009 6:23 pm
by AlexAdams
Klaus,
I am prompted to save the stack before the closeStack message handler has a chance to do anything.
Any other ideas?
Posted: Thu Aug 27, 2009 7:20 pm
by Klaus
Hi Alex,
ah, yes, that is an ugly inconvenience of the IDE that you cannot switch off

But this will NOT happen in a standalone, if that is what you mean.
Best
Klaus
I wondered about that
Posted: Thu Aug 27, 2009 7:41 pm
by AlexAdams
Thanks. I'll setup a machine to test that. Does it work the same if the person is using Revolution Player?
Posted: Thu Aug 27, 2009 9:21 pm
by Klaus
Hi Alex,
yes the Rev Player behaves like a standalone.
Best
Klaus
Posted: Thu Aug 27, 2009 9:55 pm
by Mark
Hi,
I would recommend using closeStackRequest instead of closeStack. In the closeStackRequest handler, you still have the possibility to cancel the close "message". For example:
Code: Select all
on closeStackRequest
-- you might remove the line below, the next line and the
-- last line if you want to auto-save without asking the user
answer "Really?" with "Yes" or "No"
if it is "Yes" then
save this stack
if the result is empty then
lock messages
-- do any additional cleaning up here
if the environment contains "dev" then
close this stack
else
quit
end if
else
beep
answer "Could not save. Want to close anyway?" with "Yes" or "No"
if it is "Yes" then
lock messages
-- do any additional cleaning up here
if the environment contains "dev" then
close this stack
else
quit
end if
end if
end if
end if
end closeStackRequest
You might want to replace the quit command with
this handler. Just make sure to just it in case you don't use MySQL or if there are any other libraries and externals that need to be stopped before quitting.
If you open the stack as modeless inside the IDE, the IDE won't ask you whether to save it and the only messages would be those from the script above.
Best,
Mark