Easiest way to retain the values of 30 variables, during SD

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
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Easiest way to retain the values of 30 variables, during SD

Post by DR White » Sat Nov 30, 2013 1:06 pm

What is the Easiest way to retain the values of 30 variables, during Shutdown?

I have a game that I want to save the names, scores and dates of the top ten players.

Any help will be appreciated!

Thanks,

David

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

Re: Easiest way to retain the values of 30 variables, during

Post by Klaus » Sat Nov 30, 2013 1:16 pm

Hi David,

sure! :D

I would do like this:
1. Create a TAB and CR delimited list from your variables
player1 TAB score1 TAB date1
player2 TAB score2 TAB date2
etc...

2. Save that list in a text file in the users "documents" folder:

Code: Select all

...
put tListOfTopPlayers into url(specialfolderpath("documents") & "/highscores")
...
3. Then on openstack read the file in again, if available:

Code: Select all

...
put specialfolderpath("documents") & "/highscores") into tHiScore
if there is a file tHiScore then
  put url("file:" & tHiScore) into aVariable
  ## do whatever you like with aVariable
end if
,,,
You get the picture :D


Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Easiest way to retain the values of 30 variables, during

Post by DR White » Sat Nov 30, 2013 1:32 pm

Klaus,

This will be a first using files in LC and we will see how things go.

I really appreciate you providing some example code!

Thanks for your incredibly fast response! :)

David

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Easiest way to retain the values of 30 variables, during

Post by DR White » Sat Nov 30, 2013 1:34 pm

I probably should have mentioned that this is for an android app.

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

Re: Easiest way to retain the values of 30 variables, during

Post by Klaus » Sat Nov 30, 2013 1:42 pm

Hi David,

specialfolderpath("documents") is also available on Android :D


Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Easiest way to retain the values of 30 variables, during

Post by DR White » Sat Nov 30, 2013 2:56 pm

Klaus,

You guidance has lead me to a maybe a simple solution. I was setting up some scroll fields to test load the variables into the file your suggested and I closed down the LC program and then reopened it. I was pleasantly surprised that the data was still in the content of “scrolling field” object (it makes since that it would be there, I am just not that sharp this morning). So I think I will try this method of saving small amounts of data, before trying the file storage method and see what happens. Without your inspiration I would not have found this option.

Thanks,

David

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

Re: Easiest way to retain the values of 30 variables, during

Post by Klaus » Sat Nov 30, 2013 3:00 pm

Hi David,

yes, this surely works in the IDE but will NOT in a standalone,
since a standalone (stack) cannot save itself!


Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Easiest way to retain the values of 30 variables, during

Post by DR White » Sat Nov 30, 2013 3:09 pm

WOW!!!

That surely would have caused me a lot of PAIN!

How is it that I can change Button labels in the standalone and not the content of a field?

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

Re: Easiest way to retain the values of 30 variables, during

Post by Klaus » Sat Nov 30, 2013 3:20 pm

Hi David,
DR White wrote:How is it that I can change Button labels in the standalone and not the content of a field?
Well, you can change and modify everything in a standalone, but this will NOT get saved!
I am talking about the mainstack and all its substacks that will go into the standalone.


Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Easiest way to retain the values of 30 variables, during

Post by DR White » Sat Nov 30, 2013 3:39 pm

Klaus,

Thanks so much for saving me from so MUCH PAIN!

Now, I will go back to see if I can make the file method work for me.

David

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Easiest way to retain the values of 30 variables, during

Post by DR White » Sat Nov 30, 2013 6:20 pm

Please give me an example for creating a text file.

I am not having much success with the above code. I am most likely doing something wrong.

Thanks,

David

Post Reply