Save to a stack

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

Post Reply
hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Save to a stack

Post by hamlynart » Thu Mar 20, 2008 12:35 pm

Hi Folks,

I'm trying to save text entered in a field of a stack using the suggested script from the preferences pane example:

on closeStack
save this stack
end closeStack

but when I reopen the stack the entered text has not saved.

Any ideas?

Thanks

Jim H

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Mar 21, 2008 10:42 am

Dear Jim,

The closeStack handler runs after the stack has closed already. At that point, you can't save the stack anymore, since it is no longer there. If you use the closeStackRequest message instead of the closeStack message, you can solve this problem:

Code: Select all

on closeStackRequest
  save this stack
end closeStackRequest
If you have any clean-up scripts, make sure they don't clean up your text field. Also, note that standalones cannot be saved.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Save to a stack

Post by hamlynart » Sat Mar 22, 2008 10:54 am

Thanks Mark,

However, that doesn't seem to make a difference - in fact it seems to disable the close window button too!? When I close a project stack in revolution it asks me to save it anyway so I'm not quite sure what advantage the script has if it doesn't work in standalone mode?

Anyway, since I couldn't get it to work the simple way (as suggested in the documentation) instead I did it the other way by saving to a preferences.txt file. Shame it couldn't all be simply bundled together though.

Thanks again

Jim H

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sat Mar 22, 2008 11:00 am

1. The posted script does not disable the close window button or any other button/element.

2. Rev always asks to save, no matter what you do. Therefore, that is not an indicator about whether your stack is actually saved or not.

3. Standalones cannot save themselves, but they can save stacks that are not part of the standalone file.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Mar 22, 2008 11:02 am

Hi Jim,

Sorry, I always write my handlers without much thinking in this forum, it seems ;-)

However, if you had looked up the closeStackRequest message in the built-in docs, you would have noticed that my script should have been

Code: Select all

on closeStackRequest
  save this stack
  pass closeStackRequest
end closeStackRequest
If you want to save data inside a stack, simply don't make it part of your standalone but keep it in the same folder as your standalone or give it a different file extension and save it in your documents folder.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply