Page 1 of 1
Saving Dataset from a LiveCode App
Posted: Mon Dec 09, 2013 3:50 pm
by aircooled76
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!
Re: Saving Dataset from a LiveCode App
Posted: Mon Dec 09, 2013 4:29 pm
by dunbarx
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
Re: Saving Dataset from a LiveCode App
Posted: Mon Dec 09, 2013 4:46 pm
by aircooled76
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...
Re: Saving Dataset from a LiveCode App
Posted: Mon Dec 09, 2013 5:13 pm
by Klaus
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
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
Best
Klaus
Re: Saving Dataset from a LiveCode App
Posted: Mon Dec 09, 2013 6:33 pm
by dunbarx
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
Re: Saving Dataset from a LiveCode App
Posted: Mon Dec 09, 2013 6:42 pm
by Klaus
Yes, but not in the "Application" folder unless the current user has ADMIN permissions

Re: Saving Dataset from a LiveCode App
Posted: Tue Dec 10, 2013 1:09 pm
by aircooled76
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!
Re: Saving Dataset from a LiveCode App
Posted: Tue Dec 10, 2013 1:33 pm
by aircooled76
Post removed as it was posted in this thread in error...
Re: Saving Dataset from a LiveCode App
Posted: Tue Dec 10, 2013 1:59 pm
by Klaus
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
Re: Saving Dataset from a LiveCode App
Posted: Tue Dec 10, 2013 3:48 pm
by aircooled76
Thanks Klous... just realized I put my post on the wrong thread!!!