This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
Ryodoan


Newbie


Joined: 25 Nov 2003
Posts: 2

Posted: 25 Nov 2003 11:19:51 pm    Post subject:

I want to store a variable as a string such as:

:For(A,1,8
:A->str1
:str2+str1->str3
:Input str3,E
:Pause
:End


it would appear like this
NUMBER 1 3
NUMBER 2 7
NUMBER 3 2
ect, ect,...
Numbers underlined are user inputed


This isnt the exact code im useing but it gives you the general idea of what im trying to do. But i know you cant store a variable as a string so hence my problem, how do i put it in a string?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 26 Nov 2003 11:09:04 am    Post subject:

Input "NUMBER:",A
"0"->Str0
While A>.1
.1A->A
sub("0123456789",10fPart(A)+1,1)+Str0->Str0
int(A->A
End
sub(Str0,1,length(Str0)-1->Str0

It only works with Integer numbers though, but you shouldn't have much problem adding non-integer support.


Last edited by Guest on 26 Nov 2003 11:10:44 am; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 26 Nov 2003 01:51:52 pm    Post subject:

The TI-83 Plus Assembly in 28 Days tutorial has a basic (?!?) program to change a number to a string. I do not remember the exact code but it involves storing {0,0} to L1, {x,x} to L2, doing LinReg(ax+b ) (Edit - the stupid forum changed my b ) to a Cool!!!), storing to Y1, etc. You should be able to write the code without too much difficulty. Also, I think doing

Code:
:Input Str3,E
would cause an error.

Last edited by Guest on 26 Nov 2003 01:52:54 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 26 Nov 2003 02:37:51 pm    Post subject:

Sir Robin wrote:
(Edit - the stupid forum changed my b ) to a Cool!!!)

Disable 'Enable emoticons?' just underneath the post's text field when typing your post.
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 26 Nov 2003 03:51:40 pm    Post subject:

More specifically it is

Code:
:{X,0}->LTEMP1
:{0,X}->LTEMP2
:LinReg(a+bx) LTEMP1,LTEMP2,Y1
:Equ>String(Y1,Str1)
:sub(Str1,1,length(Str1)-4)->Str1
:DelVar LTEMP1
:DelVar LTEMP2
:DelVar Y1


Note that it uses LinReg(a+bx) (STAT / CALC + 8 ) and not LinReg(ax+b) (STAT / CALC + 4).


Last edited by Guest on 26 Nov 2003 03:52:28 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 27 Nov 2003 02:34:16 pm    Post subject:

You could also do it like this:


Code:
:{0,1} -> L1
:{X,X} -> L2
:LinReg(ax+b) L1,L2,Y1
:Equ>String(y1,Str1
:sub(Str1,4,length(Str1)-3 -> Str1
:DelvarL1DelvarL2DelvarY1


doesn't matter really
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 03 Dec 2003 12:26:55 am    Post subject:

Im so confused. How could i get something froma string and load it into a variable??? I tried

sub(str0,A,1)->S

But that doesnt work. Any other ideas???
Back to top
Ryodoan


Newbie


Joined: 25 Nov 2003
Posts: 2

Posted: 03 Dec 2003 09:16:02 am    Post subject:

Input str3,E

This works, maybe my calculator (TI-83+) is a freak, but it works :)

Well, while i was editing my and deleteing some unwanted code I accidently deleted a "little" to much.... heh.... translation i got delete happy and cleared the last 30 lines that i wanted to keep... I'll try this again in a little bit.


Last edited by Guest on 03 Dec 2003 04:33:31 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 03 Dec 2003 12:16:13 pm    Post subject:

Jedd wrote:
Im so confused.  How could i get something froma string and load it into a variable???

expr(string)->variable

For example:

expr(Str0)->A

or:

expr("12345678")->A

or:

expr(sub(Str0,1,4))->A


Last edited by Guest on 03 Dec 2003 12:16:57 pm; edited 1 time in total
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 03 Dec 2003 11:04:37 pm    Post subject:

pchooahh! thanks a bunch...it works now!


another thing...
how can i store just one letter into a string without changing the entire string? like if the 30th character in Str9 was a T, but i want to make it a W, or a 7 to 5 or whatever. i tried "5"->sub(Str9,30,1) and 5->sub(Str9,30,1) but obviously sub( works the other way. I guess i could store everything before it into a string (Str1), then everything after it into a string (Str2), and then add it altogether with the variable i want (Str1+"5"+Str2->Str9) but that would take forever. any other ideas?


Last edited by Guest on 04 Dec 2003 01:05:50 am; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 04 Dec 2003 10:29:31 am    Post subject:

Replace first occurance of 'T' in Str9 with 'W':

instring(Str9,"T")
sub(Str9,1,Ans-1)+"W"+sub(Str9,Ans+1,length(Str9)-Ans-1)->Str9

You can of course replace Ans with instring(Str9,"T") and have it all on just one line:

sub(Str9,1,instring(Str9,"T")-1)+"W"+sub(Str9,instring(Str9,"T")+1,length(Str9)-instring(Str9,"T")-1)->Str9
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 04 Dec 2003 01:04:17 pm    Post subject:

yes, but what if "T" was the first or last letter? that wouldnt work...

Code:
inString(Str1,"T";find out where T is...
If not(Ans;"T" isnt in the string
Return; so quit
sub(sub(" "+Str1,1,Ans)+"W"+sub(Str1+" ",Ans+1,length(Str1)-Ans+1),2,length(Str1)->Str1;replace the "T"


Last edited by Guest on 04 Dec 2003 01:11:15 pm; edited 1 time in total
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 04 Dec 2003 07:36:19 pm    Post subject:

coolness. that'll work for what i need to do.
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement