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

0 Members and 1 Guest are viewing this topic.

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
How do you write a string to the basic variable Ans?
« on: November 28, 2010, 06:33:56 pm »
How do you write a string to the basic variable Ans?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #1 on: November 28, 2010, 06:35:18 pm »
Whenever you use a string it is stored in Ans. For example:
:"HELLO
:If Ans="HELLO
:Pause Ans

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #2 on: November 28, 2010, 06:39:13 pm »
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.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #3 on: November 28, 2010, 06:42:32 pm »
Wait a minute... Axe... Oops? I believe a similar question came up before, but I do not remember where. Sorry...

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 #4 on: November 28, 2010, 06:42:50 pm »
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.
« Last Edit: November 28, 2010, 06:43:05 pm by Deep Thought »




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #5 on: November 28, 2010, 06:43:16 pm »
I also think it could be moved.

Anyways, here's a screnie

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 #6 on: November 28, 2010, 06:48:42 pm »
You should be able to use Data(4,TAns,0) as a name with GetCalc() to create or modify Ans as a string.
"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 #7 on: November 28, 2010, 06:51:58 pm »
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
« Last Edit: November 28, 2010, 06:53:06 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: How do you write a string to the basic variable Ans?
« Reply #8 on: November 28, 2010, 06:56:17 pm »
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 :) .

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #9 on: November 28, 2010, 07:04:23 pm »
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 ;)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

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 #10 on: November 28, 2010, 07:22:49 pm »
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.
"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 #11 on: November 28, 2010, 08:07:33 pm »
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.

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 #12 on: November 28, 2010, 08:13:23 pm »
It'd be something like
"TEST"->GetCalc(Data(4,TAns,0

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: How do you write a string to the basic variable Ans?
« Reply #13 on: November 28, 2010, 08:17:05 pm »
No, you have to copy data. So more like this:
Code: [Select]
Copy("TEST",GetCalc(Data,4,[sup]T[/sup],0,0),4
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

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 #14 on: November 28, 2010, 08:18:15 pm »
That makes more sense. I'd forgotten about the Copy( token.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ