Name
InsertStr -- insert substring into string with optional overwriting (V4.5)
Synopsis
var$ = InsertStr(s$, sub$, pos[, overwrite, encoding])
Function
This function inserts sub$ into s$ at the position specified by pos (0 means beginning of the string). The position needs to be specified in characters, not in bytes. If the optional argument overwrite is set to True, sub$ will overwrite any characters that were previously there on the insert position.

The optional encoding parameter can be used to set the character encoding to use. This defaults to the default string encoding set using SetDefaultEncoding(). See Character encodings for details.

Inputs
s$
string to insert sub$ into
sub$
substring to insert
pos
position at which to insert sub$ in characters (0 means beginning)
overwrite
optional: whether the sub$ should overwrite characters in s$ or shift them to the right (defaults to False which means no overwriting)
encoding
optional: character encoding to use (defaults to default string encoding) (V7.0)
Results
var$
resulting string
Example
Print(InsertStr("Hollywood is a very cool program!", " very", 19))
The above code prints "Hollywood is a very very cool program!"


Print(InsertStr("Hollywood is a very cool program!", "good", 20, True))
The above code prints "Hollywood is a very good program!"

Show TOC