Variable Modify String

 

The functions discussed in this topic modify the values of text string variables previously created in the macro.

 

 

Script Editor > Expand Variables Category > Variable Modify String

 

Don't process embedded variables

This option is for use when the variable being modified contains variables or a combination of % symbols. Select this option to have the macro ignore any variables embedded in the variable to be modified.

 

In the image above, we will assume that the variable %Start% contains another variable - %T[15]%. When the "Don't process embedded variables" option is selected %T[15]% is saved to the %Results% variable rather than the expanded value of the variable.

 

This feature is available for the following Variable Modify String options: Append Text, Copy Whole Text, Copy Part of Text, Replace Substring, Save to Clipboard, Save to Text File, Append to Text File, Save to INI File and Save to Environment Variable.

 

 


 

 

Trim

The Trim option removes all spaces and control characters on the left and on the right of the text string variable being modified.

 

 

Left Trim

Left Trim removes all spaces and control characters to the left of the text string variable being modified.

 

 

Right Trim

Right Trim removes all spaces and control characters to the right of the text string variable being modified.

 

 

Strip CR/LF

Strip CR/LF removes any Carriage Returns and Line Feeds embedded in the text string variable being modified.

 

 


 

 

Convert to Integer

Use this function to convert the value of a text string variable to an integer variable. If the text variable does not contain a valid value to be converted to an integer (i.e. non-numeric characters), then the integer value is set to zero.

 

 

Convert to Decimal

Use this option to convert the value of a text string variable to a decimal variable. If the text variable does not contain a valid value to be converted to a decimal (i.e. non-numeric characters), then the decimal value is set to zero.

 

 

Append Text

The Append Text function adds text to the end of an existing text string variable.

 

Text to Append

Insert the text to be added to the variable selected.

 

 

Append Text String Variable

The Append Text String Variable command combines the contents of one text variable with another text variable. The text is appended to the end of the receiving variable.

 

Text Variable

Select the variable to receive the additional text from the second variable.

 

Text Variable to Append

Select the variable to be appended to the first string variable.

 

 


 

 

Copy Whole Text

The Copy Whole Text command copies the contents of a text string variable to new text string variable.

 

Text Variable

Select the variable to receive the copy.

 

Text Variable to Copy

Select the variable to be copied to another variable.

 

 

Copy Part of Text

The Copy Part of Text function copies a portion of the contents of one text string variable to another text string variable. Specify the starting position and the number of characters to copy. The starting position and the characters to copy can be set to either a value or set to an integer variable. Integer variables can be created using the length of a text variable or the position of text in a text variable, providing much greater flexibility in determining what to copy.

 

Text Variable

Select the variable to receive the copy.

 

Variable to Copy From

Select the variable from which to copy a portion of the text.

 

Starting Position

The Starting Position indicates the first character to copy. To start with the 5th character in the variable, insert 5 as the starting position.

 

Number of Characters to Copy

Insert into this field the number of characters to copy.

 

 

Delete Part of Text

The Delete Part of Text command deletes a portion of the contents of a text string variable. Specify the starting position and the number of characters to delete. The starting position and the characters to delete can be set to either a value or set using an integer variable. Integer variables can be created using the length of a text variable or the position of text in a text variable, providing much greater flexibility in determining what to copy.

 

Text Variable

Select the variable from which to delete part of the text.

 

Starting Position

The Starting Position indicates the first character to be deleted. If starting with the 5th character in the variable, insert 5 as the starting position.

 

Number of Characters to Delete

Insert in this field the number of characters to delete.

 

 

Uppercase

The Uppercase command converts the entire contents of a text string variable to uppercase letters.

 

 

Lowercase

The Lowercase command converts the entire contents of a text string variable to lowercase letters.

 

                

Pad Left

The Pad Left function pads the left side (beginning) of a text string variable with spaces. Specify the width that the resulting variable should occupy. For example, if the text variable contained the name "Fred" and the Pad Left width is set to 15, a total of 11 spaces would be added to the left side of (before) "Fred" since "Fred" takes up 4 spaces (4 + 11 = 15). The pad left can be used for right justifying values such as columns of numbers.

 

Width of Text

Insert the total width that the variable should occupy.

 

  

Pad Right

The Pad Right function pads the right side (end) of a text string variable with spaces. Specify the width that the resulting variable should occupy. For example, if the text variable contained the name "Fred" and the Pad Right width is set to 15, a total of 11 spaces would be added to the right side (end) of "Fred" since "Fred" takes up 4 spaces (4 + 11 = 15). The pad right can be used for left justifying values.

 

Width of Text

Insert the total width that the variable should occupy.

 

 

Replace Substring

The Replace Substring option locates a string of text within the text string variable and replaces it with other text.

 

Text to Replace

Enter the text found in the variable selected that is to be replaced.

 

Replace Text With

Insert the text to replace the text currently found in the variable.

 

Replace All Instances

Check this box to have every instance of the text string replaced. With this box not checked, the first instance of the text string is replaced. Any other instances are ignored.

 

Ignore Case

The Ignore Case option ignores upper and lower case letters in the substring. The replacement takes place even if the case does not match. If this option is not selected, an exact match is required in order for the replacement to occur.

 

 


 

 

Save to Clipboard

This option saves the contents of the selected text string variable to the Windows Clipboard.

 

 

Save to Text File

Save to Text File saves the contents of the selected text string variable to a text file.

 

Filename

Select the file to receive the text saved to the variable. Insert the name of the file and path or click on the Browse button to locate the text file.

 

Add a Trailing CR/LF

This option inserts a carriage return or line feed to the end of the text string that is saved to the text file.

 

 

Append to Text File

Append to Text File appends the contents of the text string variable to the end of a text file. The text is positioned after any text that already exists in the file.

 

Filename

Select the file to receive the text saved to the variable. Insert the name of the file and path or click on the Browse button to locate the text file.

 

Add a Trailing CR/LF

Add a Trailing CR/LF option inserts a carriage return or line feed at the end of the text string saved to the file. Any subsequent appending to the text file would start on a new line.

 

 

Save to INI File

Save the contents of a text string variable to an INI file.

 

INI File Name

Insert the INI file name and path in this field or click on the Browse button to locate the file.

 

Key - Insert the Key name in this field.

Value - Insert the Value name in this field.

 

 

Save to Environment Variable

Windows maintains "global" variables that the system can access at any point. Some common ones are as follows:

 

temp -- holds the location of the temporary folder on the computer

windir -- holds the folder name where windows is installed

path -- holds a number of folder names where files should be searched if a file cannot be found in the current folder

 

Use this command to set up environmental "global" variables for later use or to modify existing variables. A complementary command that can "read" an environment variable is part of the Variable Set String commands.

 

 

Additional information about Environmental Variables from Microsoft

 

To determine which Environment variables exist on your computer, run the Command Prompt. Type set in the Command Prompt window and press Enter to view the Environment variables.

 

--- Definition #1 ---

 

Environment variable

An element of the operating system environment, such as a path, a directory name, or a configuration string. Environment variables are typically set within batch files.

 

--- Definition #2 ---

 

Environment variables specify search paths for files, directories for temporary files, application-specific options, and other similar information. The system maintains an environment block for each user and one for the computer. The system environment block represents environment variables for all users of the particular computer. A user's environment block represents the environment variables the system maintains for that particular user, including the set of system environment variables.