TIB: Re: string manipulation


[Prev][Next][Index][Thread]

TIB: Re: string manipulation




> On a basic not, is it possible to do make a string and change the letter of
> one of the letters in that string?
>
> example:
>
> "abc"->a
> sub(a,2,1->b
> "l"->sub(a,2,1
>
> so that the letter b would be 'b'.  Then, could you change that to 'l' for
> example, so you would have "alc" as a?  I need to know for a text scrambler.

Well, you can't just store the string into another string without overwriting the
whole thing.  What you could do, though, is add the beginning part of the string
(which you don't want to change) with the part you want to change, plus the end of
the string.

Ex.- to get from "abcde" to "a1cde"
        you add "a"+"1"+"cde"

General source from ti-86:
    where x = # position in word, "y" = new string
:"..."-->a
:sub(a,1,x-1)+"y"+sub(a,x+1,(lngth a)-x)-->a
gets you "...y..."

General source from ti-89:
: "..." --> a
: left(a,x-1) & "y" & right(a,(dim a)-x) --> a

Hope this helps,

~Dave <the_regul8r@bigfoot.com>



References: