Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: PC5LeGeND on May 30, 2012, 12:41:14 pm

Title: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 12:41:14 pm
I want to create a game wich saves to lists like: L1 but it gives me an error when i trie it like: 5->L1(1)

Does anybody know how to do it ???

Please answer if it will work it will certainly be a fantastic game

Title: Re: External variables in axe parser
Post by: Keoni29 on May 30, 2012, 12:45:15 pm
This is axe, not BASIC. L1 in axe is just another pointer to a location in free RAM. You can use appvars to store savefile data in. There are some great tutorials here about appvars.
Title: Re: External variables in axe parser
Post by: Hayleia on May 30, 2012, 12:45:27 pm
Here (http://www.omnimaga.org/index.php?action=articles;sa=view;article=58) is a tutorial about external vars.
But maybe you don't need external vars, maybe writing to free Ram would be enough. I don't know what your game is but you may want to learn about pointers too :)
Title: Re: External variables in axe parser
Post by: parserp on May 30, 2012, 12:49:58 pm
Well, if you want to save stuff temporarily wile in the program, you can use safe RAM areas like L1.
There are 712 bytes, and you can refer to them like: {L1}, {L1+1}, up to {L1+711}.
Of course, you can also store stuff into them.

As far as saving goes, like saving a high-score, etc. You can use appvars. To do this, you do:
Code: [Select]
GetCalc("appvTEST",2)->A     //make an appvar called TEST which is 2 bytes large and store it into pointer A
B->{A}r              //When B is your highscore, store it into A (the appvar) with 2 bytes. (using the superscript r)
I'd also refer to this tutorial (http://www.omnimaga.org/index.php?action=articles;sa=view;article=58) about external vars.

Also, welcome here. :D Please introduce yourself in this thread: http://www.omnimaga.org/index.php?board=10.0


EDIT: :ninja:
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 12:55:32 pm
I really need a sort of list so i can store coordinates in it can someone help me with that ?
Title: Re: External variables in axe parser
Post by: Keoni29 on May 30, 2012, 12:56:47 pm
Well... You could at least have a look at those tutorials first :/
Title: Re: External variables in axe parser
Post by: Hayleia on May 30, 2012, 12:56:48 pm
If it is just when the game is running, try doing {L1+X} instead of L1(X-1) ;)
No need for external vars
Title: Re: External variables in axe parser
Post by: parserp on May 30, 2012, 12:57:26 pm
I really need a sort of list so i can store coordinates in it can someone help me with that ?
Exactly. Rather than doing "L1(1)", do "{L1}". same with "L1(3)", do "{L1+2}".


EDIT: :ninja: again x.x
Title: Re: External variables in axe parser
Post by: Keoni29 on May 30, 2012, 01:05:19 pm
Please read the tutorial!!!!
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 01:13:58 pm
Ok thank you it works
but another problem i want to know the dim from a list does it work with dim({L1}???
Title: Re: External variables in axe parser
Post by: Hayleia on May 30, 2012, 01:14:34 pm
L1 has no "dimension". The only thing we could say is that it contains 712 bytes.
It is just free ram, not a list.

In fact, Axe's syntax is close to Basic but it is not Basic ;)
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 01:29:36 pm
You cant get like how many numbers it got
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 01:45:30 pm
But yeah it will be without lvl editor
Title: Re: External variables in axe parser
Post by: Hayleia on May 30, 2012, 01:50:42 pm
You cant get like how many numbers it got
There is no command like this but it is not that difficult to code in a subroutine. Assuming your list doesn't include any zeros just do this
_______________________

Fill(L1,711,0)
.this at the very beginning of your program

...
your code here
...
Return
.End of your code

Lbl Dim
0->r2
{r1}
While
 r2++
 {r1++}
End
Return r2
_______________________

Then using Dim(L1) (with an uppercase D) should return the number of elements "in" L1 (if I didn't do any mistakes)
Title: Re: External variables in axe parser
Post by: FinaleTI on May 30, 2012, 01:52:06 pm
PC5LeGeND, please try to avoid double posting.

Quote from: The Rules
Double-posting (posting two messages in the same topic in quick succession) is discouraged.
  • Double-posting to "bump" a thread that hasn't been replied to for a day is permitted.
  • For special cases (such as a major project update), use your own discretion.
  • Remember that you can always use the "MODIFY" buttons to edit the content of a post.
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 01:55:24 pm
Oh srry i didnt know that i was double posting srry
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 02:30:06 pm
Omg it works thank you guys i will maybe do a pre release soon
Title: Re: External variables in axe parser
Post by: Hayleia on May 30, 2012, 02:30:54 pm
You just double posted again D:
Title: Re: External variables in axe parser
Post by: Keoni29 on May 30, 2012, 02:31:03 pm
Yay a pre-release :3 You play minecraft I assume XD
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 30, 2012, 03:12:25 pm
Yeah i play minecraft but i didnt double post or does it mean i post 2 times after eachother ?? Than srry about that i thought it mean you post 2 times the same
Title: Re: External variables in axe parser
Post by: C0deH4cker on May 30, 2012, 03:41:19 pm
If your "list" contains zeros, then you will need to make a counter variable that simply stores the length of the array. For example, L could be the length, and the array would be in L1. Then, whenever you want to append data to the array:
myNum->{L + L1}
L++


To read the last element:
{L-1+L1}

To remove an element, you can either write the last element as zero and then decrement the length counter, or simply decrement the length counter if you know that you won't be reading from after the array.
Title: Re: External variables in axe parser
Post by: Hayleia on May 31, 2012, 12:54:29 am
i didnt double post or does it mean i post 2 times after eachother ?? Than srry about that i thought it mean you post 2 times the same
Yes, double posting is posting 2 times in a row, not necessarily the same post :)

If your "list" contains zeros, then you will need to make a counter variable that simply stores the length of the array. For example, L could be the length, and the array would be in L1. Then, whenever you want to append data to the array:
myNum->{L + L1}
L++


To read the last element:
{L-1+L1}

To remove an element, you can either write the last element as zero and then decrement the length counter, or simply decrement the length counter if you know that you won't be reading from after the array.
Or still use my method with a number X other than zero that is not in the list :P

_______________________

Fill(L1,711,0)
.this at the very beginning of your program

...
your code here
...
Return
.End of your code

Lbl Dim
0->r2
{r1}
While -X
 r2++
 {r1++}
End
Return r2
_______________________
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 31, 2012, 12:58:59 am
My lvl editor works but if i want to get values from my list it say invalid dim is there a command so that i can strore it and acces from my caculator OS
Title: Re: External variables in axe parser
Post by: Keoni29 on May 31, 2012, 12:58:50 pm
My lvl editor works but if i want to get values from my list it say invalid dim is there a command so that i can strore it and acces from my caculator OS
No
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 31, 2012, 02:15:54 pm
That...is a problem
Title: Re: External variables in axe parser
Post by: parserp on May 31, 2012, 03:04:16 pm
Why would you want to use the OS's lists? It is much easier to use free ram areas and appvars.
Title: Re: External variables in axe parser
Post by: PC5LeGeND on May 31, 2012, 03:28:31 pm
But what is the command to store in your appvar
Title: Re: External variables in axe parser
Post by: Keoni29 on May 31, 2012, 03:34:02 pm
But what is the command to store in your appvar
There is no such thing. You just write a value to an adress. Like this:
Code: [Select]
GetCalc("appvTEST",2)->A //A is the pointer to your appvar now!
10->{A} //stores 10 in appvar TEST
21->{A+1} // stores 21 in appvar TEST
disp{A}>Dec //Displays 10 in this case
disp{A+1}>Dec //Displays 21 in this case
Title: Re: External variables in axe parser
Post by: parserp on May 31, 2012, 03:36:02 pm
Code: [Select]
GetCalc("appvNAME",[size of data you need])->A     //appvar NAME is created with the amount of data you need and stored to pointer A.
Copy([your data],A,[size of your data])                  //Copy's the size of your data from your data into pointer A (appvar NAME)

EDIT: :ninja:
Title: Re: External variables in axe parser
Post by: Keoni29 on May 31, 2012, 06:59:37 pm
Code: [Select]
GetCalc("appvNAME",[size of data you need])->A     //appvar NAME is created with the amount of data you need and stored to pointer A.
Copy([your data],A,[size of your data])                  //Copy's the size of your data from your data into pointer A (appvar NAME)

EDIT: :ninja:
For a level editor it might be better to copy the level data to free ram and copy it back to the appvar, indeed, so that you don't end up destroying the level without a spare save file.