Saving variable when a stack is closed
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 6
- Joined: Mon Nov 18, 2013 8:34 pm
Saving variable when a stack is closed
Hey all, I was wondering if there is any way to stop a variable from being deleted when a stack is closed. For instance in my project I am using a variable called playcounter, this variable is supposed to count how many times the program has been run but any values it holds are deleted when the stack is closed. Any help will be greatly appreciated and thanks in advance
Re: Saving variable when a stack is closed
You need to save in an external file. I suggest you to add:
Then you can add:
Code: Select all
on preOpenStack
set itemDel to "/"
set the defaultFolder to item 1 to -2 of (the effective fileName of this stack)
end preOpenStack
Code: Select all
put playcounter into URL "file:./playcounter"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Saving variable when a stack is closed
Hi TheApexEffect,
Max' solution may work in the IDE, but probably NOT in any standalone because of missing write permissions!
Better use a suitable "specialfolderpath()" for the platform you want to write your info!
Best
Klaus
Max' solution may work in the IDE, but probably NOT in any standalone because of missing write permissions!
Better use a suitable "specialfolderpath()" for the platform you want to write your info!
Best
Klaus
Re: Saving variable when a stack is closed
Is this indeed for a standalone? If it is, use the "splash screen" method to allow your main working stack to be able to save data. If not, set a custom property to hold the value.
Craig Newman
Craig Newman
Re: Saving variable when a stack is closed
My solution works also in standalone applications. 

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Saving variable when a stack is closed
Max.
Certainly. Just options...
Craig
Certainly. Just options...
Craig
Re: Saving variable when a stack is closed
Not on desktop, only if the current user has ADMIN permissions!MaxV wrote:My solution works also in standalone applications.
An "average" user cannot write into the platform specific "Applications" folder on Mac and Win!
Not to talk about -> specialfolderpath("engine") on mobile, which is exactly what your script will point to

Re: Saving variable when a stack is closed
I use that tecnique on Windows Xp, Windows Vista, Windows 8 and Linux every day and it works.Klaus wrote:Not on desktop, only if the current user has ADMIN permissions!MaxV wrote:My solution works also in standalone applications.
An "average" user cannot write into the platform specific "Applications" folder on Mac and Win!
Not to talk about -> specialfolderpath("engine") on mobile, which is exactly what your script will point to

On Linux I am not root.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Saving variable when a stack is closed
Now I understood what you means.
My applications are never in system protected folders, my applications are located in user folders like "Documents".
My applications are never in system protected folders, my applications are located in user folders like "Documents".

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Saving variable when a stack is closed
HA! 
Your message contains 6 characters. The minimum number of characters you need to enter is 10.

Your message contains 6 characters. The minimum number of characters you need to enter is 10.