Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Raylin on March 03, 2010, 09:23:09 pm

Title: Questions with commands
Post by: Raylin on March 03, 2010, 09:23:09 pm
I started using Axe today (like five minutes ago).
So, as expected, I r newfeg.

I am having issues with the word NAME in the documentation.
How do you declare a name? And what is meant by VAR?
Because I threw in the variable A to see what it did.
Axe threw back an error. :(

Little help, please?
Title: Re: Questions with commands
Post by: trevmeister66 on March 03, 2010, 09:51:40 pm
Im no expert with Axe, but I believe VAR can be replaced with any BASIC variable (A-Z), and maybe more.
Title: Re: Questions with commands
Post by: Raylin on March 03, 2010, 10:02:13 pm
Lies and slander, I say!

Any other clarifications?
Because the variable A most definitely threw back an error.
Title: Re: Questions with commands
Post by: DJ Omnimaga on March 03, 2010, 10:05:48 pm
i don't see where there is lies and slander. Remember axe is still in dev so bugs can arise
Title: Re: Questions with commands
Post by: trevmeister66 on March 03, 2010, 10:07:54 pm
Post the code that you are using. Maybe theres something else thats wrong
Title: Re: Questions with commands
Post by: Quigibo on March 03, 2010, 10:20:29 pm
Supported Vars are A-Z
Supported Names are Pic00-Pic9Z, Str00-Str9Z, and GDB00-GDB9Z (These can also be single numbers)
Supported Labels are 00-ZZ (These can also be single letters/numbers)

By the way, there is a really annoying bug I am trying to fix right now where sometimes when you try to compile the first time, it throws a random error, but if you try again, it will compile correctly.  Perhaps this is what happened?
Title: Re: Questions with commands
Post by: DJ Omnimaga on March 03, 2010, 10:30:52 pm
Someone reported this IIRC. When this compile error occurs, does the person program runs fine after it compiled successfully? Does random crashes occur?
Title: Re: Questions with commands
Post by: Raylin on March 03, 2010, 10:46:24 pm
:A
:Disp >Dec

That's all that I wrote.
And, on the same note...

:[FFFF]->RAWR

Help me with this epic fail of a program.
Title: Re: Questions with commands
Post by: Builderboy on March 03, 2010, 11:19:49 pm
Alright I see the problem here, You are not storing anything to A. Axe isn't as flexible as Basic when it comes to things like Ans.  To dsplay the number in A, you would do

:Disp A>Dec

and to store a number into A, it works just like Basic

:9->A

Note that you can only store integers (whole numbers) from 0 to 63655.  Secondly, with your sprite (i think?) sprites should have at least 16 characters defining them, as sprites are 8x8, and 1 char is needed for every 4 pixels.  And also you store sprites to Picture variables, not names variables.  Like Quigibo said earlier you can have any one picture token followed by either a letter or a number.  So to store a sprite you could do this:

:[FFFFFFFFFFFFFFFF]->Pic1

Which would store a black 8x8 sprite into Pic1
Title: Re: Questions with commands
Post by: calc84maniac on March 04, 2010, 01:46:42 pm
Also, remember that these are not the real A and Pic1 variables from Basic. That's just what we're calling them.
Title: Re: Questions with commands
Post by: Raylin on March 04, 2010, 02:19:29 pm
Intriguing.
As I began to delve into the code that makes the starship move, I think I stumbled upon what Quigibo meant by NAME int the documentation.
I think he meant that if you put a letter after the variable (like Pic1, Str1) makes the variable a NAME...

I don't know. Correct me if I'm wrong.
Now, I'm trying to figure out how to use bytes in my game...
Will screwing up the syntax or the name of the byte RAM clear me?
Title: Re: Questions with commands
Post by: Quigibo on March 04, 2010, 04:14:23 pm
A "NAME" is basically a static pointer to data, meaning that once you store some data, like a string or sprite, you can refer to that data again using it's name.  Please remember, the variables and names have NOTHING to do with the variables that Basic programs use.  Pic1 is just a NAME , it doesn't mean the picture that's in the calculator.

Have you ever programed in other languages?  In practically all other languages, they don't come with predefined variables like "A" or "Str1" you have to declare them on your own.  Like in C, if you want to create a variable to keep track of the time, you might have to do this:

int time = 20

The word "time" isn't referring to the system clock or some other actual quantity of time.  Instead, you are defining it yourself to mean whatever you want!  You could have called it "pizzas" if you want, since the meaning is simply the meaning you give to it.

Now in Axe Parser, since the calculator has to compile the code, but doesn't have a lot of memory to store long names, only short names are allowed.  In fact, they have to be so short that you only get 1 type, 1 number and 1 letter/number.  So if you had a string you want to name, you would do this:

"Hello World"->Str1

Just like "time" in the previous example, Str1 isn't the system Str1, its just a name and it could have been anything.  If you want, you can do this:

"Hello World"->Pic1
Disp Pic1

And it will be exactly the same as if you called it Str1.  There is no difference, its just a name.  That's why I call it a NAME instead of separate PICS, STRINGS, and GDB variables, because they're all identical.  Tacking on extra letters just makes a longer name, that's it.
Title: Re: Questions with commands
Post by: Raylin on March 04, 2010, 07:11:09 pm
Oooohhh.
That clarification JUST made Axe that much better.
:D
Title: Re: Questions with commands
Post by: DJ Omnimaga on March 04, 2010, 09:46:32 pm
it was alerady good before the clarification you know lol  :P

Just probably not as clear to everyone for that part
Title: Questions with commands
Post by: chucktheduck on February 18, 2022, 01:16:23 pm
hello
i just started using axe yesterday and wrote a simple program, and don't understand how "if" works. I've come here from Ti basic
here is my code
input"BRUH"->Str1
"BRUH"->Str2
GetCalc(Str2)->A
GetCalc(Str1)->P
If P=A
Disp"YAY"
End
!If P=A
Disp"NO"
End

I want it to only display "YAY" when "BRUH" is input, but for some reason it always outputs "YAY" no matter the input.
i am confused
Title: Re: Questions with commands
Post by: E37 on February 19, 2022, 06:30:30 pm
hello
i just started using axe yesterday and wrote a simple program, and don't understand how "if" works. I've come here from Ti basic
here is my code
input"BRUH"->Str1
"BRUH"->Str2
GetCalc(Str2)->A
GetCalc(Str1)->P
If P=A
Disp"YAY"
End
!If P=A
Disp"NO"
End

I want it to only display "YAY" when "BRUH" is input, but for some reason it always outputs "YAY" no matter the input.
i am confused

@chucktheduck
Transitioning from BASIC to Axe is a pretty big jump. Although Axe's syntax looks like BASIC, it works in a completely different way. Very, very few segments of code work in both Axe and BASIC. You should be familiar with how pointers work. If you aren't, you should really spend 10-20 minutes reading about them because Axe uses them heavily. If you don't understand them, Axe will be one frustrating mess to use.


Code: [Select]
input"BRUH"->Str1 While this is valid syntax, it won't do what you think it does. It actually translates to:
Code: [Select]
:input
:"BRUH"->Str1
Which means it gets the user's input, does nothing with it and then stores the pointer of the string "BRUH" to Str1. Names like Str1 or GDB1 are constants. Their value can't change once the program has compiled. (The data they point to can change) This means they can't hold any value that you can't figure out when the program is compiled. Use variables to do that instead. Doing input->Str1 won't work because the value input returns may change, instead you need to use a variable like A. So: input->A


input returns a pointer to tokens. Tokens are different than characters because they can be 1 or 2 bytes long. I won't explain how they work because it is a bit complex. But if you stick to uppercase letters and numbers you will be safe because they are all 1 byte.

When debugging it is always useful to print the values of variables. Even if you are sure what they are, it is never a bad idea. :Disp A will try to print a string so it will look like gibberish. Instead, use Disp A>Dec to display it as a number. In your case, no matter what you input A and P will both hold 0. GetCalc returns a pointer to a file if the file exists in RAM or 0 otherwise. GetCalc("YAY") or GetCalc("BRUH") both return 0 because there is no file with either of those names. (So P = A) Files are things like "prgmTEST" or "appvSOMEDATA" You can use GetCalc to read and write to programs and appvars. I'm not sure what you are trying to do with it, but the documentation for it isn't very clear so I assume you misunderstood what it does.


Here is some code that should do what you want. I haven't tested it but I'm pretty sure it will work.
Code: [Select]
:.Comments start with a period. You don't need to include them in your code
:input->A            .Get a pointer to the entered tokens
:"BRUH"->Str2        .Get the pointer to the characters B, R, U, H. This line can be put anywhere in the program and it will function the same. I like to put my data at the end but that is up to personal preference.
:                  .If you want to test if two strings are equal, you need to loop over them and compare every byte.
:0->X                  .X holds where we are in the string. To compare equality, you need to loop over every byte in the string and compare it. (This is what other languages do too, they just hide it from you)
:1->Y                 .Y holds 1 for true. If we find an inequality, we should set it to 0 because the strings aren't equal
:For(length(Str1))         .Loop for the 'length' of Str1 Since input returns tokens and not characters, this may not work correctly if you use anything besides uppercase letters and numbers. (I won't explain why now because tokens are pretty complex)
:                              .The single argument for loop just runs the given amount of times. For(5) will run the body of the loop 5 times.
:!If {A + X} = {Str1 + X} .If the characters aren't equal save the value 0 to Y so we know they aren't the same
:0->Y
:End
:X++            .Increment X to the next character
:End
:
:If Y            .If Y is not 0 then the strings are equal
:Disp "YAY"
:Else
:Disp "NO"
:End


Additionally you can use Equ>String(A, Str1) to do the same thing as the loop. It is a good idea to understand how the loop works. Note that Equ>String returns 0 if the strings ARE equal and non zero if they ARE NOT.


If you haven't already, install a shell like zStart or DoorsCS7 to allow you to edit your code from archive. (this isn't a recommendation, its practically a must) Messing up in Axe means your calculator resets RAM so any programs left there will be deleted. I recommend zStart because it lets you press ON+Zoom to compile and run your code from within the editor as well as use ON+Vars to show a list of all Lbl's that you can then teleport your cursor to. Much easier than Alpha scrolling for large programs.


That was a lot. Hopefully I explained it all clearly. (If not, I am happy to explain more - I get really excited talking about Axe!)