Saving Dataset from a LiveCode App

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

Post Reply
aircooled76
Posts: 38
Joined: Mon May 20, 2013 3:14 pm

Saving Dataset from a LiveCode App

Post by aircooled76 » Mon Dec 09, 2013 3:50 pm

Hi Guys,

I have a sports scoreboard controller I am building and I need to have access to two sets of player names (one for each team.) I need to build a way of saving the information that has been entered into the application. It is not a lot of data... probably playernumber, FirstName, LastName and a image URL x about 15 players per team.

I was initially thinking of saving an XML file that I can reload when recalling the information. I have struggled to find a tutorial or example that I can get to work...

So I have a two part question.... 1. Is XML the best way to achieve this outcome, is there a better way 2. Any suggestions on how to make this work would be great!

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

Re: Saving Dataset from a LiveCode App

Post by dunbarx » Mon Dec 09, 2013 4:29 pm

Hi.

You can certainly save to an external file. But I naturally tend to simply save in a custom property or even a field. This keeps the data in the stack, which I find comforting. The format of your data is up to you, but why not keep it simply as text?

Craig Newman

aircooled76
Posts: 38
Joined: Mon May 20, 2013 3:14 pm

Re: Saving Dataset from a LiveCode App

Post by aircooled76 » Mon Dec 09, 2013 4:46 pm

Hi Craig,

Thank you for your input... I was under the impression I can't save data inside a standalone app... how exactly would I save it inside the stack?

I would have a combination of different teams each week...

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

Re: Saving Dataset from a LiveCode App

Post by Klaus » Mon Dec 09, 2013 5:13 pm

Hi aircooled,

you cannot save data inside of a standalone,
you need to save them somewhere in an external file!

I usually use a simple TAB delimited textfile, this will work with thousands of "records"!
To store multiline text in ONE item in a line I urlencode that data :D

And you can even store a complete ARRAY*** in a text file, if that is how you organize
your data in your app.

***
1. "arrayencode" the array
2. "base64encode" that
3. "urlencode" that and
4. save it to a simple textfile on disk :D


Best

Klaus

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

Re: Saving Dataset from a LiveCode App

Post by dunbarx » Mon Dec 09, 2013 6:33 pm

Klaus is correct, but a common practice is to use a "splash screen", a stack which does little except to act as the executable, and then have another stack file as your working stack. The splash oftentimes simply displays an introductory window, and then passes on to the main stack, or it can be hidden completely. The other stack files are attached in the standalone preferences dialog. Very straightforward.

The executable cannot be saved to. All the others can be.

Craig

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

Re: Saving Dataset from a LiveCode App

Post by Klaus » Mon Dec 09, 2013 6:42 pm

Yes, but not in the "Application" folder unless the current user has ADMIN permissions :D

aircooled76
Posts: 38
Joined: Mon May 20, 2013 3:14 pm

Re: Saving Dataset from a LiveCode App

Post by aircooled76 » Tue Dec 10, 2013 1:09 pm

Thanks guys,

I got this sorted by saving to a CSV txt file...

My save button text looks like:

Code: Select all

on mouseUp
   ask file "Select a location to save to"
    if the result is not "cancel" then
       put it after tfilename
       --Card: Controller
   put fld "T1name" of card "Controller" & comma into savedata
   put fld "T2name" of card "Controller" & comma after savedata
   put fld "t1fullname" of card "Controller" & comma after savedata

-- and so on for 139 entries
      
   put savedata into url ("file:" & tFilename) 
end if
end mouseUp
My load button looks like this:

Code: Select all

on mouseUp
   answer file "Select a file you want to load"
    if the result is not "cancel" then
       put it into tfilename
       put url ("file:" & tFilename) into loaddata
       
       --Card: "Controller"
       put item 1 of loaddata into fld "T1name" of card "Controller"
       put item 2 of loaddata into fld "T2name" of card "Controller"
put item 3 of loaddata into fld "t1fullname" of card "Controller"

-- and so on for 139 entries       

end if
end mouseUp
Thanks to everyone for your assistance!

aircooled76
Posts: 38
Joined: Mon May 20, 2013 3:14 pm

Re: Saving Dataset from a LiveCode App

Post by aircooled76 » Tue Dec 10, 2013 1:33 pm

Post removed as it was posted in this thread in error...
Last edited by aircooled76 on Tue Dec 10, 2013 3:48 pm, edited 1 time in total.

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

Re: Saving Dataset from a LiveCode App

Post by Klaus » Tue Dec 10, 2013 1:59 pm

Hi aircooled,

looks like this thread is finished successfully:
aircooled76 wrote:Thanks guys,
I got this sorted by saving to a CSV txt file...
So please continue your UTF questions in the other thread with the same topic:
http://forums.runrev.com/phpBB2/viewtop ... 2&start=15

Thanks!


Best

Klaus

aircooled76
Posts: 38
Joined: Mon May 20, 2013 3:14 pm

Re: Saving Dataset from a LiveCode App

Post by aircooled76 » Tue Dec 10, 2013 3:48 pm

Thanks Klous... just realized I put my post on the wrong thread!!!

Post Reply