on startup and on shutdown
Klaus Major
klaus at major-k.de
Sun Jan 11 10:24:12 EST 2004
Hi Thomas,
>> ...
>> And "closestack" or "closestackrequest" or something the best place
>> to cleanup things
>> before you leave...
> My problem with the preopenstack is that I have a lot of substacks
> that I don't want to use
> what is in the preopenstack handler. That is why the startup looks so
> good.
> The docs say it is only called once but each time I open a substack it
> 'reloads'
> all of the things in the main stack's preopenstack which I don't want
> to happen.
In this case you can put your "preopenstack"-handler into the
card-script of the first card!
This way the substacks will not execute this handler :-)
> ...
>> http://lists.runrev.com/pipermail/use-revolution/2003-December/
>> 026781.html
> Thanks for the link. I was aware of that discussion. But the docs say
> you can store info
> in a custom prop on shutdown. They even say that 'that is what the on
> shutdown and
> on startup are for'. They don't say "But wait, you then have to save
> the custom prop in
> a separate stack etc.!
> That was why I asked, because after reading the thread you reference
> before I thought
> that that was the only way BUT then I read in the docs that you can do
> it in a custom prop????
Well, fact is standalones CANNOT save themselves!
In this case you will have to store your info/prefs outside the
standalone...
And saving in the folder where the standalone resides may cause
permission-problems
on OS X, Linux and Win2000 & XP...
You could create an invisible stack, give it a name, store your
info/customprops in that stack
and save it in the appropriate folder using my function.
This way you have almost unlimited space to store info at once!
Since any new stack will automatically have one card, you can use the
stack or card
customprops and additionally their custompropertysets!
I call it "storeprefs" here in my example.
"safe_place_to_store_my_bloody_prefs" is definitively too long :-)
When your app starts you can check with my function if there is already
a prefs-file, then
read the customprop(s) of that file and do whatever you want with this
info :-)
on preopenstack
if there is a file (storeprefs() & "yourprefs.prf") then
put the myinfo of stack (storeprefs() & "yourprefs.prf") into xyz
## do whatever you want with xyz
else
## do whatever you like, since this is probably the first start of
your app
## on the end-users computer ;-)
end if
...
end preopenstack
And on "closestack" or whenever you can do this:
on closestack
##collect your info into xyz...
if there is a file (storeprefs() & "yourprefs.prf") then
## even no need to add the REV suffix
set the myinfo of stack (storeprefs() & "yourprefs.prf") to xyz
save stack (storeprefs() & "yourprefs.prf")
else
create invisible stack "myprefs" ## or whatever
set the myinfo of stack "myprefs
save stack "myinfo" as (storeprefs() & "yourprefs.prf")
end if
...
end closestack
You get the picture ;-)
!!!Not tested, but should work...
(Famous last words ;-)
Hope that helps...
Regards
Klaus Major
klaus at major-k.de
www.major-k.de
More information about the use-livecode
mailing list