Saving user modifications to Table Data

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

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Saving user modifications to Table Data

Post by trags3 » Thu May 01, 2014 4:39 pm

I am trying to put a few fields of data into a table and then be able to populate those fields with the table data when the app opens.
The data in the table reverts to the data that was in the table before it was modified by the user when the app is closed.
What am I missing?
I have just a few lines (5 right now) that I would like to have a new user enter the first time he uses the app and modify later if required. Phone number, email address etc.

Tom

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Saving user modifications to Table Data

Post by magice » Thu May 01, 2014 4:54 pm

My preferred method of doing this is to create another stack. create custom properties of the stack for each of the variables you want to save. Do not save that stack as a stand alone. When the user enters his information, set the custom properties of that stack to those values. To load those values just put in an openStack script that reads them and puts them where you want them.


Hint: don't forget to save that stack after setting custom properties.

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Saving user modifications to Table Data

Post by trags3 » Thu May 01, 2014 5:06 pm

magice wrote:My preferred method of doing this is to create another stack. create custom properties of the stack for each of the variables you want to save. Do not save that stack as a stand alone. When the user enters his information, set the custom properties of that stack to those values. To load those values just put in an openStack script that reads them and puts them where you want them.


Hint: don't forget to save that stack after setting custom properties.
Do I create the stack from within the app? If not how is that stack distributed to new devices?
I'm really new at this.

Thabks
Tom

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Saving user modifications to Table Data

Post by magice » Thu May 01, 2014 5:32 pm

trags3 wrote:
Do I create the stack from within the app? If not how is that stack distributed to new devices?
I'm really new at this.

Thabks
Tom
Create it separately, and include the file as an external. An .exe file cannot save itself or another .exe but it can change and save a .rev/.livecode file.

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Saving user modifications to Table Data

Post by trags3 » Thu May 01, 2014 6:24 pm

magice wrote:
trags3 wrote:
Do I create the stack from within the app? If not how is that stack distributed to new devices?
I'm really new at this.

Thabks
Tom
Create it separately, and include the file as an external. An .exe file cannot save itself or another .exe but it can change and save a .rev/.livecode file.
Thanks, Ill try that. Here are the steps as I understand them
1. create a new mainstack file with 1 card and a simple table as an object on the card.
2. set the properties of the card to fit my data needs.
3. include the .livecode stack file in the externals when I create the .apk file for the main app.

Is that about right?

Appreciate the help.
Thanks
Tom

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Saving user modifications to Table Data

Post by magice » Thu May 01, 2014 6:33 pm

trags3 wrote:
Thanks, Ill try that. Here are the steps as I understand them
1. create a new mainstack file with 1 card and a simple table as an object on the card.
2. set the properties of the card to fit my data needs.
3. include the .livecode stack file in the externals when I create the .apk file for the main app.

Is that about right?

Appreciate the help.
Thanks
Tom
That is the basics of the process. I'm sure you can figure out the details. If you have more questions, let us know.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Saving user modifications to Table Data

Post by dunbarx » Thu May 01, 2014 9:07 pm

I am sure Magice and you can work this out.

Just so I understand, when you said, in your initial post, that you saved data to a "table", did you mean to a variable? A table normally means a table field, an object who's contents survives sessions. I am confused, because you also said that the data in the "table" reverts to some earlier contents. No variable could do this, even if it were useful to do so.

Anyway, you do not need another stack, Use custom properties directly. These survive between sessions, and can hold much more varied data than a variable could ever dream of, if the need arises.

Craig Newman

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

Re: Saving user modifications to Table Data

Post by Simon » Thu May 01, 2014 11:19 pm

Hi Tom,
Here is the lesson on it:
http://lessons.runrev.com/s/lessons/m/4 ... pplication

I actually prefer to use a plain text file as it's easy to open and read but a stack can hold binary data (images).

(if Craig is right then don't read this post)
Doh! :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Saving user modifications to Table Data

Post by trags3 » Fri May 02, 2014 3:25 pm

I am trying to learn and use the table with custom properties approach to this problem.
On a card I have 5 text entry fields that I can enter agent information in.
Name, Cell, Office phone,etc. I have a table field tagentinfo with 5 custom properties agentname,agentcell etc.
I have a button to press when edits are complete. This is the example code for one of the entry field's data I have for the button.

On mouseUp
put the agentname of fld "tagentinfo" into "tvar"
put fld "Aname" into "tvar"
set the agentname of fld "tagentinfo" to "tvar"
end mouseUp
The script stops on the set command.

This is how Ii understand the user manual suggests this kind of operation but I am still missing siomething.
Tom

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

Re: Saving user modifications to Table Data

Post by Klaus » Fri May 02, 2014 3:34 pm

Hi Tom,

I guess tvar is a variable, right?
Then do NOT put quotes around it, or it will turn into a simple string!
...
put the agentname of fld "tagentinfo" into tVar
## This will overwrite the content of the custom prop of your field with a new value in the variable!
put fld "Aname" into tVar
set the agentname of fld "tagentinfo" to tVar
...


Best

Klaus

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Saving user modifications to Table Data

Post by trags3 » Fri May 02, 2014 4:02 pm

Klaus wrote:Hi Tom,

I guess tvar is a variable, right?
Then do NOT put quotes around it, or it will turn into a simple string!
...
put the agentname of fld "tagentinfo" into tVar
## This will overwrite the content of the custom prop of your field with a new value in the variable!
put fld "Aname" into tVar
set the agentname of fld "tagentinfo" to tVar
...


Best

Klaus
Thanks everyone. I am slowly getting it.

Tom

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Saving user modifications to Table Data

Post by dunbarx » Fri May 02, 2014 4:27 pm

Glad to hear it.

Why do you place the contents of the custom property into the variable, and the immediately place the field contents into that variable. The second will replace the first, correct? It looks like you do not need the first line.

Craig

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Saving user modifications to Table Data

Post by trags3 » Fri May 02, 2014 5:24 pm

dunbarx wrote:Glad to hear it.

Why do you place the contents of the custom property into the variable, and the immediately place the field contents into that variable. The second will replace the first, correct? It looks like you do not need the first line.

Craig
Thanks Craig, I only did that because I was copying the example on pg 223 of the User Manual.
Going back and looking at that I think they are changing just 1 word in a longer string.
I am changing the whole thing so I think you are correct.

Tom

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Saving user modifications to Table Data

Post by trags3 » Fri May 02, 2014 8:41 pm

magice wrote:
trags3 wrote:
Thanks, Ill try that. Here are the steps as I understand them
1. create a new mainstack file with 1 card and a simple table as an object on the card.
2. set the properties of the card to fit my data needs.
3. include the .livecode stack file in the externals when I create the .apk file for the main app.

Is that about right?

Appreciate the help.
Thanks
Tom
That is the basics of the process. I'm sure you can figure out the details. If you have more questions, let us know.
magice

I seem to have everything working within Livecode IDE.

When I open the Main app and the Project browser I also need to open the AgentData stack that contains the table of stored data.
What is stumping me is how to include the AgentData stack when I build the app to test on my phone. For that matter when I build the apk file how do I include the AgentData stack as an external?

Tom

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Saving user modifications to Table Data

Post by magice » Fri May 02, 2014 8:50 pm

In the standalone application settings, go to the stacks tab. Hit the add stack file button and choose you stack. This will include that stack with your stand alone app.

Post Reply