Author Topic: Lists and appvars  (Read 2594 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Lists and appvars
« on: February 22, 2013, 12:08:52 pm »
How do you store an entire list in AXE as an appvar?

not {L1} but the entire L1
I am Bach.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Lists and appvars
« Reply #1 on: February 22, 2013, 12:22:18 pm »
How do you store an entire list in AXE as an appvar?

not {L1} but the entire L1
By the fact you said "list", I fear you haven't unserstood the difference between "pointer" and "variable".
Anyway, here is a working code.

"appvNAME"→Str0

GetCalc(Str0,768)→A
!If
 .the appvar was not created, maybe you don't have enough RAM
 .in this case, maybe the program should exit safely instead of copying random bytes to a random place
End
Copy(L1,A,768)
.you can unarchive the appvar here if you want

Of course, if you don't use the full 768 bytes of L1, you can make a smaller appvar and copy less than 768 bytes.

edit For a complete tutorial on how to use appvars (among other things), see this tutorial and give +1s to FinaleTI :)
« Last Edit: February 22, 2013, 12:23:45 pm by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Lists and appvars
« Reply #2 on: February 22, 2013, 12:24:58 pm »
The steps are as follows :
  • Create your appvar using GetCalc(appvarName,size), where in this case size should be 768 since you want to store L1 which is 768 bytes large. The GetCalc function returns a pointer on the appvar, so keep it in a variable.
    Example : you want to create the appvar called LIST which is 768 bytes large and to store his address into P. You'll do something like :GetCalc("appvLIST",768)→P. Don't forget that "appv" must not be typed by hand, but by pressing [2nd] [8].
  • Use Copy(pointer1, pointer2,size) to copy the 'size'th first bytes starting at 'pointer1' into the 'size'th first bytes starting at 'pointer2'.
    In this case, since you want to copy the first 768 bytes from L1 to your appvar P, you'll do Copy(L1,P,768). But if you don't specify any size, Axe will automatically make it 768, so you can also optimize this line by Copy(L1,P).

That's all, if you don't understand something just ask :)
« Last Edit: February 22, 2013, 12:25:33 pm by Matrefeytontias »

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: Lists and appvars
« Reply #3 on: February 22, 2013, 12:58:10 pm »
How do you store an entire list in AXE as an appvar?

not {L1} but the entire L1
By the fact you said "list", I fear you haven't unserstood the difference between "pointer" and "variable".
Anyway, here is a working code.

"appvNAME"→Str0

GetCalc(Str0,768)→A
!If
 .the appvar was not created, maybe you don't have enough RAM
 .in this case, maybe the program should exit safely instead of copying random bytes to a random place
End
Copy(L1,A,768)
.you can unarchive the appvar here if you want

Of course, if you don't use the full 768 bytes of L1, you can make a smaller appvar and copy less than 768 bytes.

edit For a complete tutorial on how to use appvars (among other things), see this tutorial and give +1s to FinaleTI :)

I understand pointers, and that a list is a pointer... I guess I should have said that I want to put a pointer in one appvar so I can point to it for save data.

The steps are as follows :
  • Create your appvar using GetCalc(appvarName,size), where in this case size should be 768 since you want to store L1 which is 768 bytes large. The GetCalc function returns a pointer on the appvar, so keep it in a variable.
    Example : you want to create the appvar called LIST which is 768 bytes large and to store his address into P. You'll do something like :GetCalc("appvLIST",768)→P. Don't forget that "appv" must not be typed by hand, but by pressing [2nd] [8].
  • Use Copy(pointer1, pointer2,size) to copy the 'size'th first bytes starting at 'pointer1' into the 'size'th first bytes starting at 'pointer2'.
    In this case, since you want to copy the first 768 bytes from L1 to your appvar P, you'll do Copy(L1,P,768). But if you don't specify any size, Axe will automatically make it 768, so you can also optimize this line by Copy(L1,P).

That's all, if you don't understand something just ask :)

Thanks for that explanation of how it works!
« Last Edit: February 22, 2013, 12:58:26 pm by pimathbrainiac »
I am Bach.