Page 1 of 1
Saving data in a substack
Posted: Mon Feb 06, 2017 6:33 am
by GregWills
Dear Forum
I have searched this topic for ages and tried many suggestions. I understand this should not be a difficult problem, but I am having no luck at getting my data sub-stack to save. I am building on a Mac, but will also need to save for Windows later.
This is my trimmed down version:
I have a ‘splash screen’ main stack and a data stack and I can save data onto the data stack (in text fields) when developing in LiveCode.
I set "Move substacks into individual subfiles" in the Standalone Application Settings then save to a standalone.
I have used both “save this stack” in the data sub-stack, and "save stack “data”" from the ‘splash screen’ stack to save the data before the application is closed/quits.
Both work … until the standalone is built.
What is the obvious thing I am missing here please!
Cheers
Greg
Re: Saving data in a substack
Posted: Mon Feb 06, 2017 8:42 am
by AndyP
I suspect you have not set the path to the substack.
For testing create 2 stacks
launcher.livecode
data.livecode
put a button in stack launcher and add this code (for live put in the on openStack handler).
Code: Select all
on mouseUp
set the itemDelimiter to "/"
get the effective fileName of this stack
set the defaultFolder to item 1 to -2 of it
if there is a stack "data.livecode" then
open stack "data.livecode"
close stack "launcher"
else
answer warning "stack " & the defaultFolder & "7myStack.livecode not found"
end if
end mouseUp
compile the launcher stack
save both the compiled launcher stack and the data.livecode stack to the same folder.
Run the launcher and test.
In a live environment you will probably want to to put your data somewhere like
specialFolderPath(26)
Re: Saving data in a substack
Posted: Tue Feb 07, 2017 5:40 am
by GregWills
Thank you Andy for your informative reply.
I had a play with your suggestion to get a better understanding of where things are kept.
However, it appears as though this wasn’t the problem. I was convinced that saving a data stack is easy but couldn’t get it to work in my standalone. While playing with your script on a laptop downstairs, I tried another basic Main stack and Data sub-stack attempt and saved it to a standalone with "Move substacks into individual subfiles" in the Standalone Application Settings selected. Then save to a standalone.
This time it worked! Pleased that I was making progress, I went upstairs to repeat this on my desktop. NO. It didn’t work. The data stack was not saved.
I bought my larger project file to my laptop and did what I originally thought was how it should work. Main stack, data substack, with builder set to "Move substacks into individual subfiles”. YES. It worked as it should.
I tried this same file again on the desktop. NO, it didn’t work.
I’ve tried various versions of LiveCode on the desktop and all have the same result. The data stack in a standalone is not saved. (Whereas they work as expected on the laptop!)
Has anyone else experienced this or have any possible explanation for this behaviour.
Cheers
Greg
Re: Saving data in a substack
Posted: Tue Feb 07, 2017 5:56 am
by GregWills
After I posted the previous post, I continued to try to understand what was going on.
It then occurred to me that the difference between the laptop computer and desktop computer was that the folder with the files on the laptop was on the desktop. On the desktop computer, the files were in a folder in an external hard drive.
As you suggested Andy, the problem was in the path!! Thanks.