Page 1 of 1

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

Posted: Sat Nov 30, 2013 1:06 pm
by DR White
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

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

Posted: Sat Nov 30, 2013 1:16 pm
by Klaus
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

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

Posted: Sat Nov 30, 2013 1:32 pm
by DR White
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

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

Posted: Sat Nov 30, 2013 1:34 pm
by DR White
I probably should have mentioned that this is for an android app.

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

Posted: Sat Nov 30, 2013 1:42 pm
by Klaus
Hi David,

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


Best

Klaus

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

Posted: Sat Nov 30, 2013 2:56 pm
by DR White
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

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

Posted: Sat Nov 30, 2013 3:00 pm
by Klaus
Hi David,

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


Best

Klaus

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

Posted: Sat Nov 30, 2013 3:09 pm
by DR White
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?

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

Posted: Sat Nov 30, 2013 3:20 pm
by Klaus
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

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

Posted: Sat Nov 30, 2013 3:39 pm
by DR White
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

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

Posted: Sat Nov 30, 2013 6:20 pm
by DR White
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