Here is a link to a command that does what both these examples does, but better !!
http://bb4w.conforums.com/index.cgi?board=addins&action=display&num=1459759911
I will replace this post later with a better tool.
For now its history...
Lets say you have a string and you want to insert a letter or word in that string in a certain spot, (using the string that you feed this command)
The command : FN_addinstr(message$,location%,characterorstringtoinsert$)
If there was a command that did this... then I missed it.
(and didn't spend time looking hard enough for it)
Anyways.. I hope this helps someone.
The insertion point is at the chosen letter position
So.. if the location is 8 and your letter is p, then p is added to location 8 increasing the string size
Code: message$="I made mistake. I really did !!"
PRINT "This is the sentence that has a mistake"
PRINT message$
PRINT "1234567^"
PRINT "So to make it simple (preserve the first 7 letters and add my letter or word at location 8"
message$=FN_addinstr(message$,8,"a")
PRINT
PRINT "The correction :"
PRINT
PRINT message$
PRINT "*************************************************************"
PRINT "The incomplete word is AT"
message$="AT"
message$=FN_addinstr(message$,1,"C")
PRINT "I added a C to location 1 and it becomes....."; message$
PRINT "So to make it simple (preserve 0 letters and put C at the beginning of the string)"
END
REM Remember: when using this function, the left of your first letter in your string is 0...
REM so if your word was AT --- adding C to make it CAT ould need a plot location of 0
DEF FN_addinstr(stringtomodify$,locationtoadd%,whatstring$)
LOCAL lengthofstring%,rightlength%,leftword$,rightword$,finalword$
lengthofstring%=LEN(stringtomodify$)
rightlength%=lengthofstring%-locationtoadd%
leftword$=LEFT$(stringtomodify$,locationtoadd%-1)
rightword$=RIGHT$(stringtomodify$,rightlength%+1)
finalword$=leftword$+whatstring$+rightword$
=finalword$
And the next sample is for removing 1 letter from a string:
The command: FN_eatinstr(message$,location%)
At location 3 you would devour that letter"
Code: message$="DOHG"
PRINT "This is the sentence that has a mistake"
PRINT
PRINT message$
message$=FN_eatinstr(message$,3)
PRINT
PRINT "The correction :"
PRINT
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_eatinstr(stringtomodify$,locationtoeat%)
LOCAL lengthofstring%,rightlength%,leftword$,rightword$,finalword$
lengthofstring%=LEN(stringtomodify$)
rightlength%=lengthofstring%-locationtoeat%
leftword$=LEFT$(stringtomodify$,locationtoeat%-1)
rightword$=RIGHT$(stringtomodify$,rightlength%)
finalword$=leftword$+rightword$
=finalword$