save content of field [SOLVED]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: save content of field

Post by Samuele » Mon Nov 29, 2021 12:52 pm

dunbarx wrote:
Fri Nov 26, 2021 6:07 pm
Do you see? You will be building with a package of two stacks instead of one. The problem is that with a one-stack build, that stack becomes the executable, which cannot be saved in any OS. But adding another stack to that build allows saving to that stack.

Craig
aha! ok thanks, that's what i couldn't understand, so when i want to save the highscore for example, what do i do? i save it also in the splash stack (for example on a label), and then write "save stack "splash" ?
thanks
and another question, does the splash stack adds a lot to the size of the app?
Samuele.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: save content of field

Post by dunbarx » Mon Nov 29, 2021 3:39 pm

Getting there...

You cannot save the splash stack. It lives ONLY as a vehicle for OTHER stacks. Those are where you do all your work and where you can save. Those are the stack files that you add to the splash stack in the Standalone Application Settings of the "File" menu of the "Stacks"" pane.

The splash stack opens when the standalone opens. That is all it does. Now in the card script of the splash stack, put a handler like this:

Code: Select all

on openCard
  go stack "myWorkingStack"
  hide stack "mySplashStack"
  end openCard
So the splash stack opens, navigates to your other stack or stacks, and hides itself. The other stacks have to have handlers that save all your work, perhaps on a closeStack message, or anywhere and anytime you like. But again, all your work is done in those other stacks.

Practice a little. Make a splash stack and another stack that does some simple thing. Make a standalone. Work it until it, er, works.

As for your other question, a splash stack (and your other stacks) add almost nothing to the size of the build. Almost all of that is due to carrying the LC engine, which is most of the application size.

Craig

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: save content of field

Post by Samuele » Mon Nov 29, 2021 10:30 pm

hi, thanks, i've tried but it doesn't work, i wrote this on the stack script

Code: Select all

on openStack
   go stack "Working"
   hide stack "Splash"
end openStack
on the computer it works and it goes right away to the "working" stack but on mobile it doesn't go and it remains into the "splash" stack...
Samuele.

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: save content of field

Post by Samuele » Mon Nov 29, 2021 10:33 pm

can i share the stacks? (if yes, how?)
thanks!
Samuele.

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: save content of field

Post by SparkOut » Tue Nov 30, 2021 8:48 am

I think it was mentioned before, but the app folder mapped to "resources" is not writeable. 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".
You should refer to the path to the data stack using the writeable location.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: save content of field

Post by dunbarx » Tue Nov 30, 2021 2:38 pm

@Sparkout.

It seems as if the mobile version is not navigating to the working stack, not that there is still a saving problem.

@Samuele. Is this in fact the case?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: save content of field

Post by dunbarx » Tue Nov 30, 2021 2:40 pm

@Samuele
can i share the stacks? (if yes, how?)
thanks!
Just attach the stacks to a post here. That is done down at the "Attachments" tab just below the text field.

Craig

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: save content of field

Post by Klaus » Tue Nov 30, 2021 4:05 pm

You need to ZIP it first!

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: save content of field

Post by Samuele » Wed Dec 01, 2021 4:25 pm

SplashTry.zip
(6.15 KiB) Downloaded 85 times
these are the two stacks, it's supposed to go to the stack Working and it does it on the computer but not on mobile (if you can standalone it and see for yourself it would be great)
thanks
dunbarx wrote:
Tue Nov 30, 2021 2:38 pm
It seems as if the mobile version is not navigating to the working stack, not that there is still a saving problem.

@Samuele. Is this in fact the case?

Craig
yep :)
Samuele.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: save content of field

Post by Klaus » Wed Dec 01, 2021 4:47 pm

In the s"Standalone Application Settings" do NOT use "Stacks" to add your second stack "Working".
Click "Copy files..." and add that stack there.

You will find it in any standalone on any platform later here -> specialfolderpath("resources")
Then you can open it with:

Code: Select all

...
put specialfolderpath("resources") & "/Working.livecode" into tTargetStack
go stack tTargetStack
hide stack "Splash"
...
If you want to save that stack at some point, please re-read SparkOut posting again!

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm
Location: Italy

Re: save content of field

Post by Samuele » Wed Dec 01, 2021 5:21 pm

Klaus wrote:
Wed Dec 01, 2021 4:47 pm
If you want to save that stack at some point, please re-read SparkOut posting again!

Code: Select all

global _gUserName

on mouseDown
   put the text of widget "fi" into _gUserName
   put _gUserName into field "la"
   if the environment is "mobile" then
      mobileVibrate 3
      --save this stack
      put specialfolderpath("resources") & "/Working.livecode" into tStackToSave
      save stack tStackToSave
   end if
end mouseDown
i don't know if it's this you meant but like this it doesn't save the app and when i close it there's nothing in the field
ideas?
thanks!
Samuele.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: save content of field

Post by Klaus » Wed Dec 01, 2021 5:28 pm

You did not read SpakOut's posting, right?
Here the important parts:
I think it was mentioned before, but the app folder mapped to "resources" is not writeable.
So your script cannot work.
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".
What does this tell you?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: save content of field

Post by dunbarx » Wed Dec 01, 2021 5:48 pm

Klaus
Click "Copy files..." and add that stack there.
I thought that pane was for external files that were NOT stack files, and that stack files were always added in the "Stacks" pane. Thinking about it now, since both are files, not stacks that are being added, I am not sure of the difference.

Is this something particular to mobile?

Craig

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: save content of field

Post by Klaus » Wed Dec 01, 2021 5:59 pm

Since that stacks needs to be copied to the Docs folder, I thought "Copy files..." would be the right place.
Toi be honset, I have no idea where stack added by "Stacks" will end up in the standalone. :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: save content of field

Post by dunbarx » Wed Dec 01, 2021 7:59 pm

Hmmm. I don't know either. Funny how I think I am fairly proficient working inside LC, but seem to be a complete newbie when working outside of LC. Outside meaning things like how to save a stack attached to a splash stack.

I never do; I always live and work in the IDE. The handful of engineers that I make stuff for seem to be able to save , but after talking to one of them, he is not sure how he does it. We do know that these guys use Windows, keep the entirety of the build in a nested "sharedDocs" folder that is not in any kind of "Documents" folder.

I understand that some folders are writable and some not. Does Windows also require an explicitly named "Documents" folder in order to save?

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”