Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: SirCmpwn on April 08, 2010, 09:05:47 pm

Title: Transitioning from TI-Basic to Axe Basic
Post by: SirCmpwn on April 08, 2010, 09:05:47 pm
Hello,
Another tutorial, this one by request.
Axe Basic gives you a lot of new functions for TI-Basic, but does not support a lot of the old ones yet.  This guide should get you off the ground with Axe.  This guide applies to version 0.1.4.  It isn't meant to replace the manual, but to compare.

Major Differences
|-------------------------------------------------------------------------------|
|TI-Basic Version                       |Axe Version                            |
|---------------------------------------+---------------------------------------|
|===Lists===                            |===RAM Areas===                        |
|Lists in TI-Basic are simply lists of  |Axe does not have lists, but rather    |
|numbers.  You can store to them like   |gives you areas of RAM to store in.    |
|so: 5→L1(1) or {5→L1.                  |                                       |
|---------------------------------------+---------------------------------------|
|===Real Numbers===                     |===Unsigned Integers===                |
|In TI-Basic, you can store numbers as  |In Axe, you can store either one or two|
|large as you like, assuming there is   |bytes of data, for a maximum value of  |
|enough memory.                         |255 and 65536 respectively.            |
|---------------------------------------+---------------------------------------|
|===Graphing===                         |===Plotting===                         |
|In TI-Basic, you can graph pixels      |In Axe, you can only plot pixels based |
|according to the window settings.      |on the dimensions of the screen, from  |
|                                       |96 to 64.                              |
|---------------------------------------+---------------------------------------|
|===Sprites===                          |===Sprites===                          |
|You can use text sprites or assembly   |Axe has sprite support built-in.       |
|libraries.                             |                                       |
|---------------------------------------+---------------------------------------|
|===Data===                             |===Data===                             |
|In TI-Basic, you could copy a list or  |All data is embedded into the source   |
|matrix, or save a picture, or the like.|using the [] tokens.                   |
|-------------------------------------------------------------------------------|

Feel free to add to the above.

Common Tasks in Axe Basic

Storing Numbers to Lists
You have two options for storing numbers: 1 byte and 2 byte.  Storing one byte values (0-255) is easy:
Code: (Axe Basic) [Select]
5→{L1}The trouble comes when you want to store to the next element in the list, which you can do like so:
Code: (Axe Basic) [Select]
5→{L1+1} // List name + offset
To store 2 byte nubmers (normal numbers):
Code: (Axe Basic) [Select]
5→{L1}ᴿ
However, storing two byte numbers has an important requirement: offsetting by two.  This is because each two byte number takes up two slots in the list.  So, to store to the second element while using two byte numbers, you should do this:
Code: (Axe Basic) [Select]
5→{L1+2}ᴿ // List name + offset * 2
I have to leave now, but I will keep editing this with more information as time progresses.  Please feel free to post questions about any of this in the topic.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: meishe91 on April 08, 2010, 09:35:13 pm
Great comparisons! Looks cool.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on April 08, 2010, 10:35:36 pm
Nice, should help even more :)

Axe is pretty similar to TI-BASIC, but it's important to know the differences.

I love how Axe is still so close to TI-BASIC in terms of syntax compared to any other TI-83 language, though.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: indubitably on April 09, 2010, 09:41:59 am
Thank you this is very helpful, I'll be checking back every now and the for updates.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: Ti-newb on April 27, 2010, 12:51:44 am
Wow this stuff is great, I like how Axe has so many tutorials on it already rofl.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on April 27, 2010, 02:07:34 am
yeah, it's a really great language, especially for people who are used to TI-BASIC. I barely learned it before and only did a small pixelating routine with the help of people, and now I ventured more into it and managed to make an entire game already (altough it's quite simple lol)
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: meishe91 on April 27, 2010, 02:31:21 am
What is the game?
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on April 27, 2010, 02:47:42 am
See topic I just posted

Altough this isn't the official version, lol
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: meishe91 on April 27, 2010, 02:57:02 am
Haha ya I just saw that, nice :D Rick Roll in the back ground is awesome :P
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on April 27, 2010, 03:02:23 am
yeah I just saw that we could have static grayscale backgrounds while everything in black on the screen can move and stuff, so I thought: hey! Why not put a text rickroll in there? :P
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: meishe91 on April 27, 2010, 03:19:10 am
Nice :P
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on April 30, 2010, 12:20:40 am
Btw just to tell how I am so used to TI-BASIC, even thought I know pointers are written like {L1+A}, in one occasion I still wrote L1(A) x.x then spent 10 minutes debugging lol
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: calcdude84se on April 30, 2010, 05:37:29 pm
Hmm... Axe seems to be more strict about closing parentheses, brackets, curly brackets, and whatnot.
BASIC habits keep getting me Axe errors. I wonder how difficult it would be to have an option for the compiler to be a bit more syntactically lax...
At any rate, yeah, Axe is definitely a good language. Now if only someone would write an on-calc assembler in assembly instead of BASIC...
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: meishe91 on April 30, 2010, 05:42:57 pm
I think that is what SirCmpwn is doing with Mosaic. I'm not sure though.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: _player1537 on April 30, 2010, 05:48:49 pm
yes, SIr is making Mosaic for that (I believe he said he might change the name).  He says it will currently assemble anything without wildcards ("ld hl,1337" uses the wildcard 1337, xor A will compile)
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on April 30, 2010, 06:38:32 pm
I still like Axe a lot. You get the speed of ASM (well, almost) with almost the ease of BASIC. I did not have much issues with closing parhentesises, but it is indeed more stricts. I guess this is just some stuff to get used to. I myself started getting used to some of it, but again, I haven't coded BASIC much in the past year, so this might be why.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: Quigibo on April 30, 2010, 08:19:14 pm
Its actually far more lax than BASIC.  Its just the change of some of the operators that might be confusing you.  The store arrow in BASIC used to mean store everything that came before it to a variable.  Now, it means store the current expression stack into a variable so you now have the freedom to use it inline.  And Axe doesn't really care much about using the enter button.  These are the same:

:A->C
:E->D

:A->CE->D

And things like this:

:A+1->A
:If A=10
:End

can reduce to this:

:If A+1->A=10
:End

And another thing most people don't know about.  The answer always carries over to the first argument of the commands.

:X
:Pxl-On(,Y)

Is actually the same as Pxl-On(X,Y) since the last expression was X and carried over.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: calcdude84se on April 30, 2010, 08:44:56 pm
Interesting... Parentheses et al. can still cause errors if mismatched, though, (e.g. For(X,L3,L3+10:{X-1->X:End, w/new lines instead of just colons, causes an ERROR:BLOCK for me) Maybe you could document what is and isn't valid?
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: _player1537 on April 30, 2010, 08:47:01 pm
"For(X,L3,L3+10):{X-1}->X:End" try that
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: calcdude84se on April 30, 2010, 08:50:53 pm
I was saying that more parentheses were more necessary than in BASIC.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on April 30, 2010, 08:53:13 pm
I wonder if in future versions of Axe he could automatically add them when compiling, for stuff like For(, for example.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: Quigibo on April 30, 2010, 09:20:09 pm
Interesting... Parentheses et al. can still cause errors if mismatched, though, (e.g. For(X,L3,L3+10:{X-1->X:End, w/new lines instead of just colons, causes an ERROR:BLOCK for me) Maybe you could document what is and isn't valid?
Really?  That should be proper syntax.  What you're telling the parser to do is to store the value X-1 into X and then read the data at that new location and do nothing with it.  If instead, you want the data at the location X-1 to store into X, then you need the closed parenthesis for this case.

If you're ever getting an error from not closing the parenthesis, let me know, becasue that should never happen, axe always adds the parenthesis at the end for you automatically like basic.  So when you type:

:{X-1->X

The parser should automatically put parenthesis at the end to make:

:{X-1->X}

And NOT this:

:{X-1}->X

As you use Axe more often, you find it is very convenient to use the arrow operator inline than it is to use it by itself.  It also optimizes the code size and speed significantly when used properly.  I can't make everything you typed so far just end every time you store, otherwise, you can't do these very efficient optimizations and coding tricks like for example: Fill(X->{L1},99) to fill ram at L1 with 100 copies of X.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: calcdude84se on May 01, 2010, 09:40:56 am
Ah, I see. That's very interesting, and definitely very useful. However, why do I get an ERROR:BLOCK? Could someone verify that this happens for them too? I'm sure that's similar to one short program I had, which received that error. I'll check again...
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on May 01, 2010, 11:22:42 am
The code above in Calcdude84se gives me ERR:BLOCK too. If I change {X+1->X}, it works fine, though. I wonder if this is some bug during parsing?
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: Quigibo on May 01, 2010, 12:14:29 pm
Yeah, it must be a bug then, I'll look into it.
Title: Re: Transitioning from TI-Basic to Axe Basic
Post by: DJ Omnimaga on May 01, 2010, 12:17:13 pm
Do not use pesticides, though. They're bad for environment.