Saving a data stack in android
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Saving a data stack in android
I have created a launcher stack that opens an application stack. I am able to access the application stack on an android device, but am not able to save the stack after I modify it. I can modify it, but can not find the right syntax to save the modifications.
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Re: Saving a data stack in android
Is it possible to save a substack(appstack) of a mainstack(launcherstack) in Android?
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Saving a data stack in android
Keith,
Welcome! Stacks included in the "Copy Files" pane will end up in specialFolderPath("engine"), you will need to copy it to specialFolderPath("documents") before you will be able to save them. This lesson isn't specifically about saving stacks, but should get you started on your way:
http://lessons.runrev.com/m/4069/l/1522 ... ile-device
Write back whenever you get stuck. This forum is filled with helpful people.
--Sefro
Welcome! Stacks included in the "Copy Files" pane will end up in specialFolderPath("engine"), you will need to copy it to specialFolderPath("documents") before you will be able to save them. This lesson isn't specifically about saving stacks, but should get you started on your way:
http://lessons.runrev.com/m/4069/l/1522 ... ile-device
Write back whenever you get stuck. This forum is filled with helpful people.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
--Sefro
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Re: Saving a data stack in android
thanks for your response. I have copied the stack to my documents folder, but do not know how to initiate a save of any modifications to my stack. Here is my code that saves it to my documents.
Now i need the syntax to save changes to the appstack. I have tried many variations of this in a button in the stack, but nothing seems to save my changes. This is one example of something I tried.
Here is another attempt of the script in a save button
Code: Select all
on openstack
set the defaultfolder to specialfolderpath ("Documents")
if there is not a file "Appstack.livecode" then
put the filename of this stack into masterfile
set the itemdelimiter to "/"
put "Appstack.livecode" into the last item of masterfile
--put specialFolderPath ("engine") & "/AppStack.livecode" into masterfile
put specialFolderPath ("Documents") & "/AppStack.livecode" into appfile
put URL ("binfile:" & masterfile) into URL ("binfile:" & appfile)
end if
go stack specialFolderPath ("Documents") & "/AppStack.livecode"
answer the filename of this stack--shows that it is in my documents folder
end openstack
Code: Select all
on mouseUp
put specialFolderPath("Document") & slash & "Appstack.livecode" into appfile
put stack "appstack.livecode" into URL("binfile:" & appfile)
end mouseUp
Code: Select all
save stack "appstack.livecode" into URL("binfile:" & specialfolderPath("documents") & slash & "appstack.livecode")
Re: Saving a data stack in android
Hi Keith,
like most things in Livecode this is a "slap-on-the-forehead" thingie:
...
save stack "appstack"
## or whatever your stack is named in Livecode, NOT the filename!
...
Important hint:
ALWAYS use parens when concatenating file- and objectnames!
....
### go stack specialFolderPath ("Documents") & "/AppStack.livecode"
go stack (specialFolderPath ("Documents") & "/AppStack.livecode")
...
Best
Klaus
like most things in Livecode this is a "slap-on-the-forehead" thingie:
...
save stack "appstack"
## or whatever your stack is named in Livecode, NOT the filename!
...
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Important hint:
ALWAYS use parens when concatenating file- and objectnames!
....
### go stack specialFolderPath ("Documents") & "/AppStack.livecode"
go stack (specialFolderPath ("Documents") & "/AppStack.livecode")
...
Best
Klaus
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Re: Saving a data stack in android
Thanks for the reply. Unfortunately, this still does not save the changes to the stack. I have a field on the stack and I type into it then click on the save button. When I close the application and open it again, the text that I had typed in is not there.
Re: Saving a data stack in android
Hi Keith,
hm, that is the way it is supposed to work!? Maybe your app did not really get updated?
Sorry, no experience with Android stuff...
Best
Klaus
hm, that is the way it is supposed to work!? Maybe your app did not really get updated?
Sorry, no experience with Android stuff...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Saving a data stack in android
Is it possible that the original copy of the stack is open in memory when you open the copied one? If so, there would be two copies in memory at the same time and the engine may be trying to save the wrong one.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Re: Saving a data stack in android
I don't think this is the problem because it opens the file in the documents folder. Any ideas how I might check this?
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Saving a data stack in android
You could insert a debugging line into the script just before you try to open the copy in the documents folder. This will give you a list of all currently open stacks: answer the mainstackskeith.izatt wrote:I don't think this is the problem because it opens the file in the documents folder. Any ideas how I might check this?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Re: Saving a data stack in android
when I run the script "answer the mainstacks" I get a message that I have the launchstack running and the appstack. Will this have some bearing on being able to save? Frustrated, this should be easy. Thank you for your continued help.
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Saving a data stack in android
Looking at your script, I'm confused about what file you are copying. It looks like you are making a copy of the currently open appstack and saving it to the Documents folder. If so, then the copy has the same name as the original, even though their file paths are different. When you open the one in documents, the engine will see two stacks with the same name and will choose an arbitrary copy to save. If it chooses the original, the save will fail because that one resides in the standalone's (locked) engine folder.
But this is what confuses me:
What is "this stack"? If it's a separate stack you've loaded after the standalone starts up, you need to close the original before opening the copy or else rename the copy. There's an issue here in that a stack that is running a handler can't be closed and removed from memory until the handler finishes, which means you can't fully close the original from within its own openstack handler. However, you can rename the copy from there, so do that.
If you want the copy to be named as the original is now, change the name of the original instead to something like "appstackTemplate". Then you can name the copy just "appstack". The above revision also checks to see if the original is open and closes it if it is, just as a precaution and because you don't need two copies open anyway. It won't fully close until the handler finishes, but it will no longer be open by the time you want to save the copy later on. I wrote the handler off the top of my head so test it in case.
A stack has three kinds of "names". It has a file name on disk (the path to the stack file,) a name (the short name) and a label (what the user sees in the title bar.) These can all be different, and the short name is always different from the filename. Referring to the stack by its filename will always identify the stack correctly; referring to the stack by the short name will cause problems if there are two same-named stacks open. The IDE protects you from opening two same-named stacks, but you need to manage that yourself in a standalone.
If my theory is correct (and all this may be a false lead) then you should be able to save appstack using its short name. However, it is also okay to refer to the stack by its filename if you want to be sure you are saving the correct copy:
But if the above works, you shouldn't need to use the filename after the setup is finished.
But this is what confuses me:
Code: Select all
put the filename of this stack into masterfile -- what is "this stack"?
set the itemdelimiter to "/"
put "Appstack.livecode" into the last item of masterfile
Code: Select all
on openstack
set the defaultfolder to specialfolderpath ("Documents")
put the filename of this stack into masterfile
if there is not a file "Appstack.livecode" then
set the itemdelimiter to "/"
put "Appstack.livecode" into the last item of masterfile
put specialFolderPath ("Documents") & "/AppStack.livecode" into appfile
put URL ("binfile:" & masterfile) into URL ("binfile:" & appfile)
set the name of stack appfile to "Copy of appfile" -- choose an appropriate name
end if
if the short name of stack masterfile is in the openstacks then close stack masterfile -- to be safe
go stack specialFolderPath ("Documents") & "/AppStack.livecode"
answer the filename of this stack--shows that it is in my documents folder
end openstack
A stack has three kinds of "names". It has a file name on disk (the path to the stack file,) a name (the short name) and a label (what the user sees in the title bar.) These can all be different, and the short name is always different from the filename. Referring to the stack by its filename will always identify the stack correctly; referring to the stack by the short name will cause problems if there are two same-named stacks open. The IDE protects you from opening two same-named stacks, but you need to manage that yourself in a standalone.
If my theory is correct (and all this may be a false lead) then you should be able to save appstack using its short name. However, it is also okay to refer to the stack by its filename if you want to be sure you are saving the correct copy:
Code: Select all
save stack (specialFolderPath ("Documents") & "/AppStack.livecode")
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Re: Saving a data stack in android
tried script and no luck. worked with it and still no luck. thanks for all your help.
Any known scripts that work for this?
Any known scripts that work for this?
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Saving a data stack in android
This should work transparently, there must be something else going on. If your Save button is in the same appstack that you want to save, then try this in the button script:
That should tell the engine to save the copy that is currently open.
Code: Select all
on mouseUp
save this stack
end mouseUp
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 14
- Joined: Mon Dec 15, 2014 4:51 am
Re: Saving a data stack in android
I disabled the code that takes me to the file in documents folder and put a button on the launchstack that reads
It answers "no such file" which leads me to believe there is no such file. Ideas?
Code: Select all
on mouseUp
set the defaultfolder to specialfolderpath("Documents")
if there is not a file "appstack.livecode" then
answer "no such file."
end if
end mouseUp