Hi there, with a little start-help from ched80 in the feature Request post and since we don´t have a setStringToken() command I´ve tried to make my own setStringToken() function that accepts Linefeed and multiple delimiters. It´s not foolproof yet and sure needs some cleaniing. I´ll continue working on it.
SetWindowSize( 1024, 768, 0 )
SetvirtualResolution( 1024, 768 )
Global Line1 as string
Line1="Press mouse to change apple," +chr(10)+"to orange."
do
if getPointerpressed()=1 then Line1=SetStringToken(Line1," ,.!?"+chr(10),5,"orange")
print(Line1)
sync()
loop
function SetStringToken(FullString as string,Delimiter as string, TargetToken as integer, NewToken as string)
DL as integer[]
DL.length = len(delimiter)
for x=1 to len(delimiter)
DL[x] = asc(mid(delimiter,x,1))
next
OldTokenCount=0: FullstringLow$=lower(Fullstring)
TokenCount = CountStringTokens(FullString,Delimiter)
if TargetToken<=TokenCount
OldToken$=getStringToken(Fullstring,Delimiter,TargetToken)
For x = 1 to TokenCount
if getStringToken(Fullstring,Delimiter,x)=OldToken$
Inc OldTokenCount
If x = TargetToken
OldTokenPosition = OldTokenCount
exit
endif
endif
next
OldTokenCount=0
For x= 1 to len(Fullstring)
If mid(FullString,x,len(oldToken$))=oldToken$
For C=1 to DL.length
If asc(Mid(FullString,x-1,1)) = DL[C] or x=1 and asc(Mid(FullString,x+len(oldToken$),1))=DL[C]
inc OldtokenCount
If OldTokenCount = OldTokenPosition
OldTokenCharPos=x
if asc(Mid(FullString,x,1))=10 then CharReturn=10 else CharReturn=0
if asc(Mid(FullString,x+len(oldToken$),1))=10 then CharReturn2=10 else CharReturn2=0
Exit
endif
endif
next
If OldTokenCharPos>0 then exit
Endif
Next
Returnstring$=Mid(Fullstring,1,OldTokenCharPos-1)+Chr(CharReturn)+NewToken+chr(CharReturn2)+Mid(Fullstring,(oldtokenCharPos+len(oldToken$)),Len(Fullstring)-(OldTokenCharPos+len(oldToken$)-1))
endif
endfunction ReturnString$
Any comments or improvements is greatly appreciated.
I never want what I know.