Here are three string functions that I've made. They will add,replace,or remove single characters from a string. Just thought I'd post them here, someone may find them useful.
An example where "Gives" becomes "Diver"
rem *******************************************
rem
rem Transforming the word "Gives" into "Diver"
rem by adding,replacing, and removing characters from a string.
rem
rem *******************************************
String$="Gives"
String$=AddToString(String$,5,"r")
String$=ReplaceInString(String$,1,"D")
String$=RemoveFromString(string$,5)
do
text 0,0,String$
loop
end
Function AddToString(t as string,spot as integer,a as string)
Length=len(t)
fIRST$=LEFT$(T,Spot)
Second$=Right$(T,Length-Spot)
Out$=First$+a+Second$
endfunction Out$
Function RemoveFromString(t as string,spot as integer)
Length=len(t)
fIRST$=LEFT$(T,Spot-1)
Second$=Right$(T,Length-Spot)
Out$=First$+Second$
endfunction Out$
Function ReplaceInString(t as string,spot as integer,a as string)
Length=len(t)
fIRST$=LEFT$(T,Spot-1)
Second$=Right$(T,Length-Spot)
Out$=First$+a+Second$
Endfunction Out$
The functions alone:
Function AddToString(t as string,spot as integer,a as string)
Length=len(t)
fIRST$=LEFT$(T,Spot)
Second$=Right$(T,Length-Spot)
Out$=First$+a+Second$
endfunction Out$
Function RemoveFromString(t as string,spot as integer)
Length=len(t)
fIRST$=LEFT$(T,Spot-1)
Second$=Right$(T,Length-Spot)
Out$=First$+Second$
endfunction Out$
Function ReplaceInString(t as string,spot as integer,a as string)
Length=len(t)
fIRST$=LEFT$(T,Spot-1)
Second$=Right$(T,Length-Spot)
Out$=First$+a+Second$
Endfunction Out$
Please post comments,
-Sixty Squares