Hi!
Is it possible to convert a number to string (in basic)? Or join a string and a number to a string variable? I didn't find a function which does something like this.
Ok it is a long drawn out process. There are 2 ways, depending on what you need.
This is the most commonly used.
There is one more but I can not find it at the moment, but I am sure someone else will post it.
If I may ask, what program do you need this for? There may be a better way.
This is the code :
Code: ?→N // your number
""→Str 1 // your string
For 1+Int log N→I To 1 Step -1
Str 1+StrMid("0123456789",1+Int (10Frac (N/10^I)),1)→Str 1
Next
It works only for unsigned numbers.
I don't think that ' ""→Str 1 ' was needed in BASIC because variables don't need to be defined. I may be wrong.
Thanks! It's a bit disappointing that there isn't a fast built-in function. In my case it's easier to use a simple if-else, I want to echo "Player 1 wins" or "Player 2 wins" only.
Aes_Sedia5 wrote:
Ok it is a long drawn out process. There are 2 ways, depending on what you need.
This is the most commonly used.
There is one more but I can not find it at the moment, but I am sure someone else will post it.
If I may ask, what program do you need this for? There may be a better way.
Please keep an eye on what board something is posted in. TI-BASIC code will not likely help answer a question about the Prizm.
Quote:
I don't think that ' ""→Str 1 ' was needed in BASIC because variables don't need to be defined. I may be wrong.
It's needed to clear variables.
Purobaz wrote:
It works only for unsigned numbers.
Easily repaired:
Code: ?→N // your number
""→Str 1 // your string
If N<0
"-"→Str 1
Abs N→N
For 1+Int log N→I To 1 Step -1
Str 1+StrMid("0123456789",1+Int (10Frac (N/10^I)),1)→Str 1
Next
Oh wow. That was an epic derp moment for me.. TOTALLy did not realize this was in the Casio section. I am going to go hide in my hole now. *slinks away*
Aes_Sedia5 wrote:
Oh wow. That was an epic derp moment for me.. TOTALLy did not realize this was in the Casio section. I am going to go hide in my hole now. *slinks away*
It happens all the time. Just make sure you look more carefully next time.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
»
Go to Registration page
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum