Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: tehalynn on November 28, 2010, 06:33:56 pm
-
How do you write a string to the basic variable Ans?
-
Whenever you use a string it is stored in Ans. For example:
:"HELLO
:If Ans="HELLO
:Pause Ans
-
Actually, anything you do is written in ans. Any function automatically stores it's value into ans. Which means that it can only be used temporarily, because as soon as you do anything that returns a value, the value of ans will change.
-
Wait a minute... Axe... Oops? I believe a similar question came up before, but I do not remember where. Sorry...
-
I actually don't know how to do it, but just to let you all know, this is in the Axe Parser subforum ;)
EDIT: Ah, ninja'd.
-
I also think it could be moved.
Anyways, here's a screnie
-
You should be able to use Data(4,TAns,0) as a name with GetCalc() to create or modify Ans as a string.
-
You can access it in Assembly through OP1. The code for the TI-OS Ans variable is 72h, followed by two bytes of 0. The variable is used for system storage, though, so it's rather volatile. I'd only recommend using it in something like a sprite editor where the user has to transfer data. If you need to store data within the program for later computation, the Ans variable might take too long to store to.
EDIT: kind of Ninja'd :P
-
I also think it could be moved.
Anyways, here's a screnie
Nah his question was about Axe so it should remain here.
By the way welcome here tehalynn :) .
-
It does need two 0's. (Unless you're ending the line with ->Str0 etc.)
For example, this line does not work: (There needs to be another 0 in the Data( sequence)
Disp GetCalc(Data(4,TAns,0
Also, the data in Ans are a series of tokens, not characters, so be aware of that ;)
-
It does need two 0's. (Unless you're ending the line with ->Str0 etc.)
For example, this line does not work: (There needs to be another 0 in the Data( sequence)
Disp GetCalc(Data(4,TAns,0
Also, the data in Ans are a series of tokens, not characters, so be aware of that ;)
Ah yeah. You only need one 0 after a two-byte name, but two 0's after a one-byte name.
-
Wow, there are lots of helpful people here! :)
Sorry I wasn't more clear, this was a question about Axe. I just found it recently and I'm impressed. I only really program on-calc so I'd been hoping for a while that somebody would make something like this.
I'm using Ans so that the string can be recalled easily after the program ends.
So let's say I want to put "TEST" into Ans. How exactly do I go about doing that? I don't entirely understand Data, TToken, and how to convert between a string and tokens.
-
It'd be something like
"TEST"->GetCalc(Data(4,TAns,0
-
No, you have to copy data. So more like this:
Copy("TEST",GetCalc(Data,4,[sup]T[/sup],0,0),4
-
That makes more sense. I'd forgotten about the Copy( token.
-
No, you have to copy data. So more like this:
Copy("TEST",GetCalc(Data,4,[sup]T[/sup],0,0),4
Code tags (and typos) murdered this. Here's what it should look like:
Copy("TEST",GetCalc(Data(4,TAns,0,0),4),4)
It's a bit cluttered, though.
-
And here comes Quigibo with his four byte alternative...
-
No, you have to copy data. So more like this:
Copy("TEST",GetCalc(Data,4,[sup]T[/sup],0,0),4
Code tags (and typos) murdered this. Here's what it should look like:
Copy("TEST",GetCalc(Data(4,TAns,0,0),4),4)
It's a bit cluttered, though.
I tried that and it didn't seem to change Ans. If I instead do Copy("TEST",GetCalc(Data(4,TAns,0,0)),4) it changes Ans to a decimal number, but not a string. I wish I understood this better.
-
Well, for one thing that code is a little different from mine (missing a ,4). But on the other hand, I just tried it now, and there is a bit of a glitch with Axe. This code only works if Ans was previously a string. The reason is that when Axe looks for an existing Ans variable to delete, it's looking for a string (and type matters because it's using chkfindsym). If it searched using findsym, it would work (but would fail for programs and appvars).
-
Well, for one thing that code is a little different from mine (missing a ,4). But on the other hand, I just tried it now, and there is a bit of a glitch with Axe. This code only works if Ans was previously a string. The reason is that when Axe looks for an existing Ans variable to delete, it's looking for a string (and type matters because it's using chkfindsym). If it searched using findsym, it would work (but would fail for programs and appvars).
A simple fix that should always successfully create Ans as a string:
Data(4,ᵀAns,0,0)→Str0AN
DelVar Str0AN
Copy("TEST",GetCalc(Str0AN,4),4)
-
Well, for one thing that code is a little different from mine (missing a ,4). But on the other hand, I just tried it now, and there is a bit of a glitch with Axe. This code only works if Ans was previously a string. The reason is that when Axe looks for an existing Ans variable to delete, it's looking for a string (and type matters because it's using chkfindsym). If it searched using findsym, it would work (but would fail for programs and appvars).
A simple fix that should always successfully create Ans as a string:
Data(4,ᵀAns,0,0)→Str0AN
DelVar Str0AN
Copy("TEST",GetCalc(Str0AN,4),4)
Odd, I thought that wouldn't work due to the same glitch. It seems to work when I do it though.
-
Well, for one thing that code is a little different from mine (missing a ,4). But on the other hand, I just tried it now, and there is a bit of a glitch with Axe. This code only works if Ans was previously a string. The reason is that when Axe looks for an existing Ans variable to delete, it's looking for a string (and type matters because it's using chkfindsym). If it searched using findsym, it would work (but would fail for programs and appvars).
A simple fix that should always successfully create Ans as a string:
Data(4,ᵀAns,0,0)→Str0AN
DelVar Str0AN
Copy("TEST",GetCalc(Str0AN,4),4)
Well that seemed to work! Thank you! And thank you everyone else who offered help.
-
Well, for one thing that code is a little different from mine (missing a ,4). But on the other hand, I just tried it now, and there is a bit of a glitch with Axe. This code only works if Ans was previously a string. The reason is that when Axe looks for an existing Ans variable to delete, it's looking for a string (and type matters because it's using chkfindsym). If it searched using findsym, it would work (but would fail for programs and appvars).
A simple fix that should always successfully create Ans as a string:
Data(4,ᵀAns,0,0)→Str0AN
DelVar Str0AN
Copy("TEST",GetCalc(Str0AN,4),4)
Thanks for the routine! So this'll work with any other type too, right?
-
By the way, isn't Data(4,TAns,0,0) simply "Ans" in quotes? That should work, if it doesn't then its a bug I need to fix.
-
By the way, isn't Data(4,TAns,0,0) simply "Ans" in quotes? That should work, if it doesn't then its a bug I need to fix.
So what's the full code for the method that should also work?
-
By the way, isn't Data(4,TAns,0,0) simply "Ans" in quotes? That should work, if it doesn't then its a bug I need to fix.
"Ans" is just $72. Store it to a pointer and you'll get $72,$00, but that's still far off from $04,$72,$00,$00.
-
Did you try that on the calculator though? It should substitute it for $04,$75,$00 like I do with picture variables, lists, and other OS variables. Tokens in quotes don't always map to the original token values if they don't have corresponding ascii values. But I suspect that it isn't working for some reason since no one seems to be using it. I'll have to fix that next version.
-
Nope, just tried it, and it's just a $72.
-
Did you try that on the calculator though? It should substitute it for $04,$75,$00 like I do with picture variables, lists, and other OS variables. Tokens in quotes don't always map to the original token values if they don't have corresponding ascii values. But I suspect that it isn't working for some reason since no one seems to be using it. I'll have to fix that next version.
But Ans is not tied to a certain data type, so you can't just generate a 4 for it.