String Utilities

StrIns

Purpose:

Insert characters into a string.

Category:

Strings

Syntax:

StrIns "source string" "dest string" "insert position" "variable"

source string

The characters to be inserted.

dest string

The destination string.

insert position

The position in dest string where the characters will be inserted.

variable

The name of a variable to store the modified string.

Example:

The following example will insert the contents of the variable [Name] into a string and store the result in a variable called [Greeting]:


StrIns "[Name]" "Hello . How are you?" "7" "[Greeting]"


StrDel

Purpose:

Delete characters from a string.

Category:

Strings

Syntax:

StrDel "source string" "start position" "length" "variable"

source string

The original string containing the characters to delete.

start position

The position of the first character to delete.

length

The number of characters to delete.

variable

The name of a variable to store the modified string.

Example:

The example below searches for spaces in the string assigned to the variable [Name] and if found removes all characters that follow. The modified string is placed back into the [Name] variable:


SearchStr " " "[Name]" "[SpacePos]"
If "[SpacePos]" ">" "0"
  Strlen "[Name]" "[Len]"
  StrDel "[Name]" "[SpacePos]" "[Len]-[SpacePos]+1" "[Name]"
EndIf


StrLen

Purpose:

Calculate the length of a string.

Category:

Strings

Syntax:

StrLen "string" "variable"

string

The string to examine.

variable

The name of a variable to store the string’s length.

Example:

In the example below, the variable [Name] contains the string "Bernard". Since this string contains seven characters, the example Action will place “7” into the variable [Size]:


StrLen "[Name]" "[Size]"


SubStr

Purpose:

Copy a portion of a string.

Category:

Strings

Syntax:

SubStr "source string" "start position" "length" "variable"

source string

The original string containing the characters to copy.

start position

The position of the first character to copy.

length

The number of characters to copy.

variable

The name of a variable to store the copied text.

Example:

The example below, copies this president’s middle name (Quincy) into a variable called [MiddleName]:


SubStr "John Quincy Adams" "6" "6" "[MiddleName]"


SearchStr

Purpose:

Search for characters within a text string.

Category:

Strings

Syntax:

SearchStr "search for" "string" "variable" "options"

search for

The characters to find.

string

The text string to search.

variable

The name of a variable to store the position of the found characters. The variable will contain 0 (zero) if the characters are not present in the string.

options

Enter "CaseSensitive" here to search using the exact characters entered. Leave this parameter blank to perform a case insensitive search (upper and lower case characters are treated the same).

Example:

The following example searches for and removes all spaces from the variable  [Name]:


SearchStr " " "[Name]" "[SpacePos]"
While "[SpacePos]" ">" "0"
  StrDel "[Name]" "[SpacePos]" "1" "[Name]"
  SearchStr " " "[Name]" "[SpacePos]" ""
EndWhile


StrUpper

Purpose:

Convert the contents of a string to upper case. Numbers and punctuation within the string are not affected.

Category:

Strings

Syntax:

StrUpper "string" "variable"

string

The string to convert.

variable

The name of a variable to store the modified string.

Example:

StrUpper "good dog" "[Result]"


StrLower

Purpose:

Convert the contents of a string to lower case. Numbers and punctuation within the string are not affected.

Category:

Strings

Syntax:

StrLower "string" "variable"

string

The string to convert.

variable

The name of a variable to store the modified string.

Example:

StrLower "GOOD DOG" "[Result]"


StrReplace

Purpose:

Replace all occurrences of a character or substring within a string.

Category:

Strings

Syntax:

StrReplace "string" "old chars" "new chars" "variable" "options"

string

The original string.

old chars

The characters to replace.

new chars

The replacement characters.

variable

The name of a variable to store the modified string.

options

Enter "CaseSensitive" here to search using the exact characters entered. Leave this parameter blank to perform a case insensitive search (upper and lower case characters are treated the same).

Example:

The following example replaces each occurrence of the word "dog" in the source string with "cat":


StrReplace "My dog is a good dog." "dog" "cat" "[Result]" ""


You can also use this Action to remove a character by leaving the replacement characters parameter empty. For example:


StrReplace "My doggy is a good doggy." "gy" "" "[Result]" ""


StrParse

Purpose:

Separate a string into multiple parts using a delimiter character.

Category:

Strings

Syntax:

StrParse "source string" "delimiter" "array variable" "count variable"

source string

The string containing the information to parse.

delimiter

The character (or characters) used to separate the elements of the string.

array variable

The name of the variable array to store the parsed elements.

count variable

The name of a variable to store the number of elements stored in the array.


Each element in the string must be separated by the delimiter character (semicolon, comma, hyphen, etc.). StrParse will use the delimiter to divide the source string into individual elements which are placed into an array based on the array variable. The count variable will be set to the number of elements stored in the array.

Example:

The example below takes a list of file names from the FileOpenBox Action and separates them into individual files:


FileOpenBox "Open" "Any File|*.*" "c:\" "[Files]" "Multiple"
StrParse "[Files]" ";" "[Names]" "[Count]"


When executed, an array based on the [Names] variable ([Names1], [Names2], etc.) will be created. Each element in the array will contain one file name. The number of elements in the array ([Count]) will be equal to the number of files selected.


PopulateStr

Purpose:

Populate variables contained within a string. VisualNEO for Windows populates most strings automatically. The exception being strings that come from an external source such as a file loaded with the FileRead or FileToVar actions. After reading, if the file contained VisualNEO for Windows style variables, you can use PopulateStr to replace all of the variables in the string with the contents of those variables.

Category:

Strings

Syntax:

PopulateStr "string" "variable"

string

The source string containing variables to populate.

variable

The name of a variable to store the modified string.

Example:

FileToVar "[PubDir]sample.html" "[RawHTML]"

PopulateStr "[RawHTML]" "[PopulatedHTML]"

BrowserLoadFromStr "WebBrowser1" "[PopulatedHTML]"