Adding a data storage stack to the documents folder

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 1:36 am

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
Tom
MacBook Pro OS Mojave 10.14

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Adding a data storage stack to the documents folder

Post by Simon » Sun Jun 22, 2014 2:52 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 3:19 am

Thanks a lot Simon. That takes a load off my mind.
Tom
MacBook Pro OS Mojave 10.14

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 4:24 am

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
Tom
MacBook Pro OS Mojave 10.14

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Adding a data storage stack to the documents folder

Post by Simon » Sun Jun 22, 2014 4:49 am

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:
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 5:11 am

OK so you mean the file name is case sensitive? Remember I'm newish to iOS. How do I delete the app during testing?
Tom
MacBook Pro OS Mojave 10.14

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Adding a data storage stack to the documents folder

Post by Simon » Sun Jun 22, 2014 5:22 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 5:38 am

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.
Tom
MacBook Pro OS Mojave 10.14

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Adding a data storage stack to the documents folder

Post by Simon » Sun Jun 22, 2014 7:19 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 4:32 pm

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.
Tom
MacBook Pro OS Mojave 10.14

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Adding a data storage stack to the documents folder

Post by Klaus » Sun Jun 22, 2014 4:58 pm

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!

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 5:25 pm

Thanks Klaus. I added an on closeStack to save and close the data stack.
Tom
MacBook Pro OS Mojave 10.14

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Adding a data storage stack to the documents folder

Post by quailcreek » Sun Jun 22, 2014 7:04 pm

The oddest thing just happened. The openStack handler stopped working. If I change it to preOpenStack it works. Anyone else run into this?
Tom
MacBook Pro OS Mojave 10.14

Post Reply