Page 1 of 1
Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 1:36 am
by quailcreek
Hi,
I have what I know is a question with a simple answer. I’m not new to LC but I am pretty new to iOS. I just spent a bit of time building a data storage stack with lots of custom properties. I want to be able to store and retrieve the properties for my app. After building the data stack I tried to add the data stack to my app in the using the standalone settings, STACKS. No joy. So, do I add it using “copy files”? How do I add the storage stack to my app bundle? My second question is how do I insure that the data stack ends up in the documents folder in the app bundle?
Thanks,
Tom
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 2:52 am
by Simon
Hi Tom,
Yes, you use "Copy Files" it will end up in specialFolderPath("engine") so you have to move it from there into specialFolderPath("documents") before you can save data to it.
Code: Select all
put url("binfile:" & specialFolderPath("engine") & "/myData.rev") into \
url("binfile:" & specialFolderPath("documents") & "/myData.rev")
Simon
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 3:19 am
by quailcreek
Thanks a lot Simon. That takes a load off my mind.
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 4:24 am
by quailcreek
Hi Simon. Shouldn't this work? Anything after the put statement in the mouseUp handler is being ignored. What am I doing wrong?
Code: Select all
global gDataStackPath
on OpenStack
if the environment is "mobile" then
put specialFolderPath("documents") into tDataStackPath
put tDataStackPath & "/MyData.livecode" into gDataStackPath
## Need to find out when to run this
if not (there is a file gDataStackPath) then
put url("binfile:" & specialFolderPath("engine") & "/myData.livecode") into url("binfile:" \
& specialFolderPath("documents") & "/myData.livecode")
else
answer "There is a file"
end if
end openstack
Code: Select all
global gDataStackPath
on mouseUp
if the environment is "mobile" then
put the cpData[“Continents”] of stack gDataStackPath into pickList
answer pickList
end if
end mouseup
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 4:49 am
by Simon
Oh Oh I think I know this one!
Mobile is case sensitive.
The other thing is to delete the app during testing to make sure the documents folder is clean.
Simon
Edited:
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 5:11 am
by quailcreek
OK so you mean the file name is case sensitive? Remember I'm newish to iOS. How do I delete the app during testing?
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 5:22 am
by Simon
Yeah, best to be consistent with mobile.
Delete the app from the device, ummm... press/click and hold till everything is shaking delete the app then click on Home.
Are you on the sim or a real device?
Simon
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 5:38 am
by quailcreek
I'm on the sym. I found it. There's a reset in the pull down. I deleted the app.
MouseUp script is still not working though. It does get further along so I think fixing the case on the file name did some good. It isn't finding the properties. The mouseUp is supposed to pull that properties and populate the choices in a pickwheel. The pickwheel shows up but it's empty.
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 7:19 am
by Simon
Better check your file
Code: Select all
global gDataStackPath
on mouseUp
if the environment is "mobile" then
set the defaultFolder to specialFolderPath("documents")
answer the detailed files
put the cpData[“Continents”] of stack gDataStackPath into pickList
answer pickList
end if
end mouseup
I just spent an hour copying a 0 byte stack and expecting it to work.
Simon
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 4:32 pm
by quailcreek
Found the problem. When I first ran the app on the sym I had not yet attached the data stack. So it created one that was obviously empty. Resetting/deleting the app from the sym fixed the problem. All runs fine now.
Do I just set the new properties in the data stack and then save it or do I need to open it as hidden first.
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 4:58 pm
by Klaus
quailcreek wrote:Do I just set the new properties in the data stack and then save it...
Yes.
quailcreek wrote:...or do I need to open it as hidden first.
No, but you need to CLOSE that stack nevertheless after saving it, or when your app closes!
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 5:25 pm
by quailcreek
Thanks Klaus. I added an on closeStack to save and close the data stack.
Re: Adding a data storage stack to the documents folder
Posted: Sun Jun 22, 2014 7:04 pm
by quailcreek
The oddest thing just happened. The openStack handler stopped working. If I change it to preOpenStack it works. Anyone else run into this?