Page 1 of 1

Save to a stack

Posted: Thu Mar 20, 2008 12:35 pm
by hamlynart
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

Posted: Fri Mar 21, 2008 10:42 am
by Mark
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

Save to a stack

Posted: Sat Mar 22, 2008 10:54 am
by hamlynart
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

Posted: Sat Mar 22, 2008 11:00 am
by BvG
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.

Posted: Sat Mar 22, 2008 11:02 am
by Mark
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