save content of field [SOLVED]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: save content of field
Stacks copied in the "copy files" section get built into the specialFolderPath ("resources") location.
On Windows, this is relative to the mainstack exe location. If that is running in a writable location then fine. If in "Program Files" maybe, maybe not, depending on user privileges.
On mobile, the resources folder is sandboxed. The originally built standalone can access this as "master app" but even the standalone cannot save there. Just "go stack" will try to open the target stack but that also needs to be in a writable location (else, as already seen it will fail). (Yes! Even just trying to open the stack without yet specifying any save actions.)
Hence, for mobile, you have to take the "template" stack you built with the "copy files" tab settings and save a copy of it from specialFolderPath("resources") to specialFolderPath('documents"). You will want to check whether that copy exists already when the app starts, or else you will overwrite any changes saved last time.
When you want to "go stack" to the stack you want to save, you need to refer to the "documents" location to which the target stack was copied the first time you ran the app.
On Windows, this is relative to the mainstack exe location. If that is running in a writable location then fine. If in "Program Files" maybe, maybe not, depending on user privileges.
On mobile, the resources folder is sandboxed. The originally built standalone can access this as "master app" but even the standalone cannot save there. Just "go stack" will try to open the target stack but that also needs to be in a writable location (else, as already seen it will fail). (Yes! Even just trying to open the stack without yet specifying any save actions.)
Hence, for mobile, you have to take the "template" stack you built with the "copy files" tab settings and save a copy of it from specialFolderPath("resources") to specialFolderPath('documents"). You will want to check whether that copy exists already when the app starts, or else you will overwrite any changes saved last time.
When you want to "go stack" to the stack you want to save, you need to refer to the "documents" location to which the target stack was copied the first time you ran the app.
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: save content of field
Sparkout is the sort of guy who knows the ins AND the outs of LC.
Craig
Craig
Re: save content of field
Well, just SOME of them maybe. I'm not in the same Klaus as class.
Re: save content of field
sorry but i'm not that good with english and often i don't understand...Klaus wrote: ↑Wed Dec 01, 2021 5:28 pmYou did not read SpakOut's posting, right?
Here the important parts:So your script cannot work.I think it was mentioned before, but the app folder mapped to "resources" is not writeable.What does this tell you?On first run, you need to check whether the stack that needs to be saved exists already in the app "documents" folder and if not, copy it there from "resources".
i tried like this but i don't even know if it's on the right track for understanding this... is it like this?
Code: Select all
on mouseDown
put the text of widget "fi" into _gUserName
put _gUserName into field "la"
if the environment is "mobile" then
mobileVibrate 1
--save this stack
put specialfolderpath("documents") & "/Working.livecode" into tStackToSave
if there is a file tStackToSave then
save stack tStackToSave
else
put specialfolderpath("resources") & "/Working.livecode" into tStackFromResources
put url("file:" & tStackFromResources) into url url("file:" & tStackToSave)
save stack tStackFromResources
end if
end if
end mouseDown
(i tried now and it doesn't work)
Samuele.
Re: save content of field
Buongiorno Samuele,
no, no, no!
At that point (on mousedown) it is already much too late, everything has to happen
before you open stack "WORKING".
The logical workflow is like this:
1. You create a standalone from the "SPLASH" stack.
All of your inclusions like the ASK and ANSWER dialogs and all externals you are using need to go into stack SPLASH!
2. On the cellphone you start the app (= stack "SPLASH").
3. The app (= stack "SPLASH") checks if there is already a stack named "WORKING" in the users DOCS folder.
4. If there isn't the app (= stack "SPLASH") copies that stack from RESOURCES to DOCS.
5. THEN the app (= stack "SPLASH") opens that stack from the DOCS folder.
6. NOW stack WORKING can be saved.
Capisce?
You need to create a little script in the SPLASH stack:
This goes into the stackscript of SPLASH!
Now you can do this in the WORKING stack:
Best
Klaus
no, no, no!
At that point (on mousedown) it is already much too late, everything has to happen
before you open stack "WORKING".
The logical workflow is like this:
1. You create a standalone from the "SPLASH" stack.
All of your inclusions like the ASK and ANSWER dialogs and all externals you are using need to go into stack SPLASH!
2. On the cellphone you start the app (= stack "SPLASH").
3. The app (= stack "SPLASH") checks if there is already a stack named "WORKING" in the users DOCS folder.
4. If there isn't the app (= stack "SPLASH") copies that stack from RESOURCES to DOCS.
5. THEN the app (= stack "SPLASH") opens that stack from the DOCS folder.
6. NOW stack WORKING can be saved.
Capisce?
You need to create a little script in the SPLASH stack:
This goes into the stackscript of SPLASH!
Code: Select all
on openstack
## Neccessary so all opened stacks can access the inclusions of stack "SPLASH"!
start using this stack
## Prepare filenames:
## Stack in RESOURCES
put specialfolderpath("resources") & "/working.livecode" into tSourceStack
## Stack in DOCUMENTS folder
put specialfolderpath("documents") & "/working.livecode" into tTargetStack
## check if we already opened the app = the WORKING stack is already in DOCS folder
if NOT (there is a stack tTargetStack) then
## Now copy the stack to the DOCS folder
put url("binfile:" & ttSourceStack) into url("binfile:" & tTargetStack)
end if
## NOW we can open that "new" stack that NOW can be saved
go stack tTargetStack
hide stack "splash"
end openstack
Code: Select all
on mouseDown
put the text of widget "fi" into _gUserName
put _gUserName into field "la"
if the environment is "mobile" then
mobileVibrate 1
## This will work now:
save this stack
...
Klaus
Re: save content of field
If you need this for the DESKTOP, too, use these folders:
Code: Select all
...
if the environment = "mobile" then
# Mobile:
put specialfolderpath("documents") into tTargetStack
else
## Desktop:
## Windows
if the platform contains "Win" then
put specialfolderpath("support") into tTargetStack
else
## Mac:
put specialfolderpath("preferences") into tTargetStack
end if
end if
put "/working.livecode" after tTargetStack
...
Re: save content of field
However if you only have some text to save, this technique seem a little OVERKILL!
-
- VIP Livecode Opensource Backer
- Posts: 7215
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: save content of field
I was thinking the same thing. It would be much easier to just write a text file to the documents folder. If the app is only for mobile it doesn't even need to be encrypted since users can't directly access it, though I probably would use encryption if the info is very sensitive.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9802
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: save content of field
Even simpler: if the data is local why does the app need to add its own login in addition to the phone's login?jacque wrote: ↑Thu Dec 02, 2021 5:40 pmI was thinking the same thing. It would be much easier to just write a text file to the documents folder. If the app is only for mobile it doesn't even need to be encrypted since users can't directly access it, though I probably would use encryption if the info is very sensitive.
Also, without a server how would password reset be handled?
You could reset without a server, but that would mean anyone using the phone can reset the password, so why have a password?
If password reset isn't available, how do they recover data if they've forgotten their password?
I think we need to learn more about this unusual use case before advising how to support it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: save content of field
thanks! that works, but when i try to save the stack as standalone it gives me this Screen Shot 2021-12-06 at 12.13.54.pngKlaus wrote: ↑Thu Dec 02, 2021 12:18 pmBuongiorno Samuele,
no, no, no!
At that point (on mousedown) it is already much too late, everything has to happen
before you open stack "WORKING".
The logical workflow is like this:
1. You create a standalone from the "SPLASH" stack.
All of your inclusions like the ASK and ANSWER dialogs and all externals you are using need to go into stack SPLASH!
2. On the cellphone you start the app (= stack "SPLASH").
3. The app (= stack "SPLASH") checks if there is already a stack named "WORKING" in the users DOCS folder.
4. If there isn't the app (= stack "SPLASH") copies that stack from RESOURCES to DOCS.
5. THEN the app (= stack "SPLASH") opens that stack from the DOCS folder.
6. NOW stack WORKING can be saved.
Capisce?
You need to create a little script in the SPLASH stack:
This goes into the stackscript of SPLASH!Now you can do this in the WORKING stack:Code: Select all
on openstack ## Neccessary so all opened stacks can access the inclusions of stack "SPLASH"! start using this stack ## Prepare filenames: ## Stack in RESOURCES put specialfolderpath("resources") & "/working.livecode" into tSourceStack ## Stack in DOCUMENTS folder put specialfolderpath("documents") & "/working.livecode" into tTargetStack ## check if we already opened the app = the WORKING stack is already in DOCS folder if NOT (there is a stack tTargetStack) then ## Now copy the stack to the DOCS folder put url("binfile:" & ttSourceStack) into url("binfile:" & tTargetStack) end if ## NOW we can open that "new" stack that NOW can be saved go stack tTargetStack hide stack "splash" end openstack
BestCode: Select all
on mouseDown put the text of widget "fi" into _gUserName put _gUserName into field "la" if the environment is "mobile" then mobileVibrate 1 ## This will work now: save this stack ...
Klaus
and the problem is that if i click on save it will show the same thing again and again , is it a problem?
Samuele.
Re: save content of field
Oh yes, this is an old LC problem!
Do this:
put this into the stack script of "Splash.livecode":
Then add this to your "on openstack" Handler:
Unfortunately LC will also execute these scripts (pre-/openstack, pre-/opencard etc...) when creating a standalone, this will prevent LC from this behavour.
Do this:
put this into the stack script of "Splash.livecode":
Code: Select all
function isBuildingStandalone
return (the environment is "development" AND there is a stack "revStandaloneProgress" AND the mode of stack "revStandaloneProgress" > 0)
end isBuildingStandalone
Code: Select all
on openstack
if isBuildingStandalone() then
exit openstack
end if
## Neccessary so all opened stacks can access the inclusions of stack "SPLASH"!
start using this stack
...
Re: save content of field
ok thanks, now i have another problem it shows only this
all the time when trying to save as standaloneSamuele.
Re: save content of field
Sorry, never saw this dialog, so I have no idea what's going wrong...
Re: save content of field
anyone has any idea why it doesn't let me save as standalone the splash stack with the working in it?
Samuele.
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: save content of field
Samuele.
Try saving another "splash/working" pair of stacks and see if they go through. Just two brand new stacks, but where one stack file is attached to the other. I assume this is what you have now.
If that works, we can then know it is something in the other that is stopping the process.
Craig
Try saving another "splash/working" pair of stacks and see if they go through. Just two brand new stacks, but where one stack file is attached to the other. I assume this is what you have now.
If that works, we can then know it is something in the other that is stopping the process.
Craig