Author Topic: How do you store to and read from Appvars?  (Read 3289 times)

0 Members and 1 Guest are viewing this topic.

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
How do you store to and read from Appvars?
« on: January 01, 2011, 09:49:28 pm »
I really never made a game that needed a lot of data, but I'm trying now.  I need some help on storing to an appvar and reading from it.  Can someone give me example code to store a series of 10 ones and zeros. To an appvar and then display the numbers?

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: How do you store to and read from Appvars?
« Reply #1 on: January 01, 2011, 09:56:19 pm »
http://ourl.ca/84305

Examine that code, it loads/reads from appvar, but also stores.

I'll edit this post later with the *exact* code that does it, also '|' is the token 2ND + 8 in the calculator. 'appvar'

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: How do you store to and read from Appvars?
« Reply #2 on: January 01, 2011, 09:58:58 pm »
Could you copy and paste that and put it in this topic without code tags?  I'm on my iPod now and code tags dontwork.
Edit: actually, I want to be able to store digits in it and read out the individual digits. Like storing numbers in basic to a list  and doing L1(C)
« Last Edit: January 01, 2011, 10:01:29 pm by yunhua98 »

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: How do you store to and read from Appvars?
« Reply #3 on: January 02, 2011, 02:23:14 am »
Basically --

"appvMYDATA"->Str1
Unarchive Str1
!If GetCalc(Str1)
Getcalc(Str1,10)->A
End
1->{A}

Attempts to unarchive the appvar MYDATA, then if it doesn't appear to exist, creates a 10 byte long appvar.  The pointer for that appvar is stored to the variable A -- use it like L1 (except smaller).
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: How do you store to and read from Appvars?
« Reply #4 on: January 02, 2011, 10:09:31 am »
"appvNAME"->Str1
Unarchive Str1
!If getcalc(Str1)->A
Getcalc(Str1,10)->A
For(B,0,9)
0->{A+B}
End
End
« Last Edit: January 02, 2011, 10:13:41 am by Fast Crash »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How do you store to and read from Appvars?
« Reply #5 on: January 02, 2011, 10:11:25 am »
Plus another End in there somewhere, but that's pretty much it. Also nice job on the optimizing :)

EDIT: Fill(?

EDIT2: squidgetx.
« Last Edit: January 02, 2011, 10:18:51 am by Deep Thought »




Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: How do you store to and read from Appvars?
« Reply #6 on: January 02, 2011, 10:12:26 am »
Yes i forgot it :D .Fixed now
« Last Edit: January 02, 2011, 10:14:31 am by Fast Crash »

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: How do you store to and read from Appvars?
« Reply #7 on: January 02, 2011, 10:17:16 am »
"appvNAME"->Str1
UnArchive
!If GetCalc(Str1)->A
GetCalc(Str1,10)->A
0->{A}r
Fill(A,10)
End

After creating your appvar you can use its pointer that was created by GetCalc (A in this case) as a pointer to free RAM just like you would with L1-L6 (like Michael Lee said)
« Last Edit: January 02, 2011, 10:18:26 am by squidgetx »

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: How do you store to and read from Appvars?
« Reply #8 on: January 02, 2011, 10:27:08 am »
If it works it's a nice optimization :)