Re: TIB: Re: Storing text on the 86
[Prev][Next][Index][Thread]
Re: TIB: Re: Storing text on the 86
C. Smith wrote:
>
> You can only turn strings (text) into a list by replacing each character in
> the string with a number and then placing that number in a list.
>
> example
>
> :"text" -> STR1
> :"ABCDEFGHIJKLMNOPQRSTUVWXYZ" -> STR2
> :for(k,1,lngth STR1,1
> :1 -> x
> :While sub(STR1,k,1) != sub(STR2,x,1) --!= is not equal--
> :1+x -> x
> :End
> :x -> LIST(k
> :End
>
> This would leave LIST with a value of {20,5,24,20} which is the numerical
> equivalent of TEXT (1=A,2=B,3=C,...).
That's a snazzy little algorithm you have there. But, how long does it
take? If I'm reading this write (and I very well might not be) does it
have to check every letter in the text string with ever letter in the
alphabet until it finds a match? Here's a slightly quicker way, if
you're interesed. (I'm assuming the 86 has an inString command?? If
don't, then this aint gunna work. For anybody that doesn't know,
inString returns a number that is the starting position of a
sub-string. ie. Str0 is JODY_SNIDER. Then inString(Str0,"ODY") would
return the number 2)
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ_->Str2
:Input Str1
:{0->L1
:For(K,1,length(Str1
:inString(Str2,sub(Str1,K,1->L1(dim(L1)+(L1(1)<>0
:End
Jody Snider
jody1@alaska.net
References: