Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Omar Chehab on December 03, 2013, 06:05:34 am

Title: Help Request - ERROR INVALID TOKEN
Post by: Omar Chehab on December 03, 2013, 06:05:34 am
What can I use to set the dimensions of a matrix if dim( isn't a valid token.
 EDIT: It seems like [A] is an invalid token, 
{7,11->dim([A]
Fill(1,[A]
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: TheMachine02 on December 03, 2013, 06:30:42 am
I fact there isn't any matrix in axe. All you can have is buffer and data, meaning that you have a long list of byte.

If you want to work with a pseudo matrix system, you can code it : for example I want a 8*8 matrix (so 64 elements)


Code: [Select]
Buffer(64)->GDB1  //I create a area Inside of the program, wich is 64 bytes long (so 1 element is one bytes)
//GDB1 is a pointer to this area, an adress use to access to it.

//if I want to acess to the element X,Y I mostly use something like this :
{Y*8+X+GDB1}

//as we work with "list", we need to jump from 8 in 8 with the Y coordinate, and 1 by 1 with the X
//brackets is used to read a byte at the adress provided inside

in general we got this :
Code: [Select]

Buffer(dimX*dimY)->GDB1

//read :
{Y*dimX+X+GDB1}
//dimX dimY dimension of the matrix.

remember though that this work with one byte value (between 0-255)

the paragraph pointer on programming rubric in the documatation pdf explain this, so you might want to read it  :P

Edit: I forget to precise it, but when you read you must set the X,Y value to the coordinate you want retrive. You can of course change the variable, or the name of the pointer
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: Omar Chehab on December 03, 2013, 07:27:34 am
Alright, so defining and reading is covered but how about writing in a certain part?
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: MGOS on December 03, 2013, 09:29:41 am
That works exactly the same way, we use the Sto-> operator to write something to the memory:

Code: [Select]
//write :
value->{Y*dimX+X+GDB1}
//dimX dimY dimension of the matrix, value an integer between 0 and 255

And keep in mind: Axe isn't like TI-Basic at all, both languages share some same keywords, but behave quite different. You cannot simply compile a TI-Basic program with Axe.
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: Omar Chehab on December 04, 2013, 12:45:11 pm
Alright, I learnt how pointers work and how they replace the TI basic variables. One thing though, how come this doesn't work?
Code: [Select]
[05050505050505050505050505050505050505050505050505]->GDB1
While A<=24
[05050505050505050505050505050505050505050505050505]
A+1->A
End
while this works:
Code: [Select]
[05050505050505050505050505050505050505050505050505]->GDB1
[05050505050505050505050505050505050505050505050505]
[05050505050505050505050505050505050505050505050505]
""
""
etc...
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: TheMachine02 on December 04, 2013, 12:49:33 pm
data are implemented in the program in compilation time, meaning that you can't use a loop to create them. In fact, you're first program is compiled like this :

Code: [Select]

While A<=24
A+1->A
End

[05050505050505050505050505050505050505050505050505]->GDB1
[05050505050505050505050505050505050505050505050505]

(all data are put at the end and are not repeat)
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: Omar Chehab on December 04, 2013, 12:54:42 pm
Alright so the solution to my problem is to just hardcode all 25 lines into it x.x? Or is there an alternate in order to compress this madness?? :w00t:
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: pimathbrainiac on December 04, 2013, 12:55:12 pm
To add on to that, if you are filling GDB1 with data that is all 5, then you should just create a buffer GDB1, and then use Fill( to fill it with 5s

Like so:

Code: [Select]
Buff([wanted size of GDB1 in Bytes])->GDB1

Fill(GDB1,[size of GDB1],5)

You can even simplify it to:

Code: [Select]
Buff([wanted size of GDB1],5)->GDB1

I suggest you read the commands.html in the axe zip. It's really helpful once you understand the basics!

EDIT: :ninja: 'd by Omar
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: Omar Chehab on December 04, 2013, 01:10:11 pm
Thanks! :D Just what I needed a buffer should have thought of that... Sorry I forgot about it... I'll re read the commands files I don't wanna bother this awesome community with my obvious questions!
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: pimathbrainiac on December 04, 2013, 01:11:24 pm
Dude, feel free to ask. I too asked some obvious questions when I was first here.
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: Omar Chehab on December 04, 2013, 01:25:02 pm
Ummm calculator froze after i ran my program, its not responding to any inputs... I have a backup but its like 3 hours old... what should i do??
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: pimathbrainiac on December 04, 2013, 01:27:12 pm
Wait until you're sure it's completely frozen, then yank the batteries out. Sorry.

What did you set [wanted size of GDB1 in bytes] to?

You're not supposed to put it in brackets if you did.
Title: Re: Help Request - ERROR INVALID TOKEN
Post by: Omar Chehab on December 04, 2013, 01:36:11 pm
Ehh no big deal, i know i didnt put [] and i put 625 bytes to buffer. First run worked fine second run froze, i think its cuz of rand^### that i put i was testing stuff just recovered and made a new backup dont worry nothing lost..