Author Topic: How do you write a string to the basic variable Ans?  (Read 7684 times)

0 Members and 1 Guest are viewing this topic.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: How do you write a string to the basic variable Ans?
« Reply #15 on: November 28, 2010, 08:20:28 pm »
No, you have to copy data. So more like this:
Code: [Select]
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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #16 on: November 28, 2010, 08:22:46 pm »
And here comes Quigibo with his four byte alternative...
« Last Edit: November 28, 2010, 08:23:10 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #17 on: November 28, 2010, 10:03:53 pm »
No, you have to copy data. So more like this:
Code: [Select]
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.
« Last Edit: November 28, 2010, 10:04:28 pm by tehalynn »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: How do you write a string to the basic variable Ans?
« Reply #18 on: November 28, 2010, 10:19:51 pm »
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).
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #19 on: November 28, 2010, 11:04:28 pm »
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:
Code: [Select]
Data(4,ᵀAns,0,0)→Str0AN
DelVar Str0AN
Copy("TEST",GetCalc(Str0AN,4),4)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: How do you write a string to the basic variable Ans?
« Reply #20 on: November 28, 2010, 11:20:34 pm »
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:
Code: [Select]
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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #21 on: November 28, 2010, 11:46:47 pm »
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:
Code: [Select]
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.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How do you write a string to the basic variable Ans?
« Reply #22 on: November 29, 2010, 07:18:54 pm »
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:
Code: [Select]
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?




Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #23 on: November 29, 2010, 08:20:30 pm »
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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #24 on: November 30, 2010, 01:26:29 am »
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?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #25 on: November 30, 2010, 10:42:00 am »
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.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #26 on: November 30, 2010, 07:26:49 pm »
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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How do you write a string to the basic variable Ans?
« Reply #27 on: November 30, 2010, 07:42:39 pm »
Nope, just tried it, and it's just a $72.




Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: How do you write a string to the basic variable Ans?
« Reply #28 on: November 30, 2010, 07:44:46 pm »
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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman