tv%=0 message$="DOHG" PRINT "This is the word that has a mistake:" PRINT PRINT message$ message$=FN_editstr(message$,3,"") PRINT PRINT "The correction :" PRINT message$ PRINT PRINT "*************************************************************" PRINT "The incomplete word is AT" message$="AT" message$=FN_editstr(message$,1,"C") PRINT "I added a C to location 1 and it becomes....."; message$ PRINT" *************************************************************" PRINT PRINT "getting the character out of the string that doesnt match and replacing it with a Z" PRINT message$="**********E**********" PRINT message$ message$=FN_editstr(message$,11,""):REM should be at the same location when I replace it PRINT message$ message$=FN_editstr(message$,11,"Z"):REM the string should be exactly the same except for the Z PRINT message$ PRINT PRINT "1) print the original message" PRINT "2) print the message with the removed E" PRINT "3) Replace the E with Z and display it" PRINT "It looks like this command works" PRINT "The offending letter is extracted and replaced by Z at location 11, so this tool appears to be working properly" PRINT "*******************************************************************************************************" PRINT "Now lets clip the sides of the message" PRINT "Now Z has 9 stars on each side" message$=FN_editstr(message$,1,"") tv%=LEN(message$) message$=FN_editstr(message$,tv%,"") PRINT message$ END REM Remember: when using this function, the first letter in your string is 1... REM so if your word was DOHG, to change it to DOG you would set location to 3 DEF FN_editstr(stringtomodify$,location%,whatstring$) LOCAL lengthofstring%,rightlength%,leftword$,rightword$,finalword$ lengthofstring%=LEN(stringtomodify$) rightlength%=lengthofstring%-location% leftword$=LEFT$(stringtomodify$,location%-1) IF whatstring$="" THEN rightword$=RIGHT$(stringtomodify$,rightlength%) finalword$=leftword$+rightword$ ENDIF IF whatstring$<>"" THEN rightword$=RIGHT$(stringtomodify$,rightlength%+1) finalword$=leftword$+whatstring$+rightword$ ENDIF =finalword$
DEF FN_editstr(stringtomodify$,location%,whatstring$) LOCAL rightlength%,leftword$,rightword$ rightlength%=LEN(stringtomodify$)-location% leftword$=LEFT$(stringtomodify$,location%-1) IF whatstring$="" THEN rightword$=RIGHT$(stringtomodify$,rightlength%) ELSE rightword$=RIGHT$(stringtomodify$,rightlength%+1) =leftword$+whatstring$+rightword$
DEF FN_editstr(a$,I%,s$) LOCAL rl% rl%=LEN(a$)-I% IF s$<>"" rl% +=1 =LEFT$(a$,I%-1)+s$+RIGHT$(a$,rl%)
|