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
Babyboy


Advanced Member


Joined: 11 Jun 2003
Posts: 499

Posted: 03 Mar 2004 05:20:53 pm    Post subject:

ok guys, i have looked at tutorials, ticalc, the manual, and posts on this site, and tries myself, but i cannot find how one finds a specific point in a string, say "ABCD"->Str0 i would like to change the 3rd one from C to N. i believe this has something to do with the dim( function, but i just cant find it!
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 03 Mar 2004 05:29:04 pm    Post subject:

"N->sub(Str0,3,1

Very usefull in combination with instring(
Back to top
Babyboy


Advanced Member


Joined: 11 Jun 2003
Posts: 499

Posted: 03 Mar 2004 08:27:41 pm    Post subject:

i luv u

whatz instring?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 04 Mar 2004 06:15:06 am    Post subject:

say you have the following string:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ->Str0

If you want to know the place of the first D in the string, you could use this:

instring(str0,"D->A

A=4

It's like doing this:
1
While not(Ans>length("ABCDEFGHIJKLMNOPQRSTUVWXYZ") or sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ans,1)="D")
Ans+1
End
If Ans>length("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):0


Last edited by Guest on 04 Mar 2004 06:16:23 am; edited 1 time in total
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 04 Mar 2004 03:09:34 pm    Post subject:

Arcane Wizard wrote:
"N->sub(Str0,3,1

ERR:SYNTAX!

sub(Str0,1,2)+"N"+sub(Str0,4,1->Str0
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 05 Mar 2004 05:23:09 am    Post subject:

Hmm, yes, strange I wrote that.

The above also shows better why it can be usefull with instring, you can just replace the 2 with instring-1 and the 4 with instring+1 and it'll replace the character.

"AHDSFJ->Str0
instring(Str0,"D
sub(Str0,1,Ans-1)+"D"+sub(Str0,Ans+1,length(Str0)-Ans->Str0
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 05 Mar 2004 05:08:23 pm    Post subject:

that only works correctly if you never choose the first character.

you must write 2 routines for that.

(3 because of the last character as well Laughing)


Last edited by Guest on 05 Mar 2004 05:08:39 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 05 Mar 2004 05:48:50 pm    Post subject:

Though I've never had problems with that, you could just do this:

" " + Str0 + " ->Str0
//replace code
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 05 Mar 2004 07:30:10 pm    Post subject:

Also you need an "If Ans" so it doesn't do your code if the letter is not in there.
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