Insert

Top  Previous  Next

 

The Insert Special Function Command allows you to Insert specified characters within a string with other specified characters.

lamp Important: Special Function commands can only be used on the right hand side of a Variable Assignment command.

Command Syntax

 

Insert,[OriginalString],[NewString],[Index]

 

The comma character after the command is compulsory as are all three parameters and the commas separating them.

 

Parameters:

 

OriginalString: The string to be modified

NewString: The string to Insert

Index: The zero based index within the original string at which to insert the new string

 

 

All three parameters are compulsory. If any required parameter is missing or invalid an error will be thrown. All parameters must be surrounded by quotation marks if one or more commas are included. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts. The NewString value will be inserted at the specified index.

lamp Important: Any string containing or consisting of one or more commas MUST be enclosed in double quotes, otherwise an error will be thrown.

Examples:

 

Insert text at a specified location:

 

Var:NewSentence=Insert,"This is a test string","no longer ",7 // Returns "This is no longer a test string"

 

Retrieve a version number and insert it into a string variable:

 

Var:Version=GetFileVersion,"C:\Program Files (x86)\Windows Media Player\wmplayer.exe"

Var:VersionString=Insert,"File Version:","%%Version%% ",13

 

See Also: Special Functions Substring GetFileVersion