Close the stack and don't ask me to save changes...

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Close the stack and don't ask me to save changes...

Post by Klaus » Mon Feb 12, 2024 8:23 pm

Code: Select all

on closeStack
    answer "Save?" with "Save" and "No"
    if it is "No" then
        // do nothing
    else if it is "Save" then
        save this stack
    end if
end closeStack
A bit less cumbersome:

Code: Select all

on closeStack
    answer "Save?" with "Save" and "No"
     if it = "Save" then
        save this stack
    end if
end closeStack
:D

Zax
Posts: 473
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Close the stack and don't ask me to save changes...

Post by Zax » Tue Feb 13, 2024 9:19 am

stam wrote:
Mon Feb 12, 2024 8:06 pm
FourthWorld wrote:
Mon Feb 12, 2024 7:11 pm
It's also worth keeping in mind the difference between why and how we save changes during development, and what gets saved for our users at runtime. That seems to be separate from this thread, but worth keeping in mind early on since windows physically attached to the standalone cannot be saved at all (OSes generally prevent app modification at runtime). User data is often best handled as a separate file and often in a format other than a stackfile. We can cover those options as the question raises; for now just keep in mind that these questions of saving are specific to developing in the IDE, and you have total control over how all of this is done in the user experience you deliver in your app.
@Richard - Zax is designing a stack for the IDE as I understand it...
You are right Richard and everything is happening as expected in a standalone environment.
My current problem is in the IDE environment, where I am trying to bypass the message sent automatically by the IDE when closing a stack "Would you like to save..."

@Stam: this is very strange, the following code works correctly (no saving on Quit)

Code: Select all

on closeStack
   answer "Save data?" with "No" or "Save"
   if (it = "Save") then
      save me
      // update and save preferences here, no cleanup needed
   end if
end closeStack
But this one causes an automatic save on Quit:

Code: Select all

on closeStack // closed by script or with built-in close box (not trapped with Quit)
   answer "Save data?" with "No" or "Save"
   if (it contains "Save") then
      save me
      // update and save preferences here, no cleanup needed
   end if
end closeStack
But hey, whatever. Your code works and that's the main thing.
Thank you for your help.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”