Variable Set String

 

The Variable Set String command assigns a value to a text string variable. Once saved to a string variable value, use the Modify String Variables command to manipulate the original values assigned in the macro.

 

 

Script Editor > Expand Variables Category > Variable Set String

 

 

Don't process embedded variables

This option is for use if the initial value text contains variables or a combination of % symbols. Select this option to have the macro ignore any variables embedded in the Initial Value field.

 

For example, select %T[15]% as the destination variable and insert %sample% in the Initial Value field. When the "Don't process embedded variables" option is selected %sample% will be stored in variable %T[15]% as %sample% rather than the expanded value of the variable.

 

This feature is available for the following Variable Set String options: Set Value Now, Set Value from Clipboard, Set Value from File, Set Value from INI File and Set from Environment Variable.

 

 


 

 

Set Value Now

Set Value Now assigns a value to the variable now, which will be used later in the macro.

 

Destination Variable

Select a variable to use or create a new string variable.

 

Initial Value

Insert the contents of the variable in this field.

 

 

Prompt for Value

Prompt for Value displays an input box during macro playback prompting the user to input a text string.

 

Destination Variable

Select a variable to use or create a new string variable.

 

Prompt

Enter text in the Prompt edit field to explain the type of value the user should input. During macro playback, the instructions appear above the input field.

 

Mask the Input

The Mask the Input option masks the text entered into the input box and is viewed as *** instead of the actual digits.

 

The dialog should always be on top

This options makes sure that the prompt window is always on top of other open windows.

 

Positioning the Prompt window

Use this feature to define the position on the screen where the input box will appear during the playback of the macro. Insert exact coordinates or use the Set Position button to set where the window should appear. See the Window Positioning topic for additional information.

 

 Hint: Setting a Default Value in the Prompt Window

 

First use the Set Value Now option. Insert the text to be set as the default. Then use the Prompt for Value option. Both options must reference the same variable, such as T[1]. When the macro is run, the prompt window displays the default value. The user can overwrite, amend, accept or append to this value.

 

Below is a sample of the commands as they would look in the Scripting Editor. "This is a test" is the default value.

 

Variable Set String %T[1]% "This is a test"

Variable Set String %T[1]% from Prompt

 

 

 

Set Value from Clipboard

Set Value from Clipboard extracts the text currently saved to the clipboard and places it into the variable.

 

Destination Variable

Select a variable to use or create a new string variable.

 

 

Set Value from File

Set Value from File loads the contents of a text file into a variable.

 

Destination Variable

Select a variable to use or create a new string variable into which the file contents will be loaded.

 

Filename

Insert the file name and path into this field or click on the Browse button to select the file to be used.

 

Strip the trailing CR/LF characters

Use this option to save the text file contents to a variable with all trailing carriage returns or line feeds removed. This does not remove all CR/LF's from the variable, just any that trail the end of the text. Use the Variable Modify String - Strip CR/LF option to remove all carriage returns or line feeds from a text variable.

 

 

Set Value to Top Most Program Name

Set Value to Top Most Program Name examines the window that is currently on top of all others and determines what program it is from. It places the program name (i.e. the EXE file name) into the variable.

 

Destination Variable

Select a variable to use or create a new string variable.

 

 

Set Value to Top Most Window Title

Set Value to Top Most Window Title examines the window that is currently on top of all others, extracts the name that is in the caption bar (i.e. the Window Title) and saves it to the variable.

 

Destination Variable

Select a variable to use or create a new string variable.

 

 

Set Value to Current Folder Name

Set Value to Current Folder Name obtains the folder name that Windows is currently pointing to and saves the name to the variable.

 

Destination Variable

Select a variable to use or create a new string variable.

 

 

Set Value From INI File

Set Value From INI File obtains a value from an INI file and places it into a variable. Specify the file name of the INI file, the section name and the key name.

 

Destination Variable

Select a variable to use or create a new string variable.

 

Filename

Insert the name and path of the INI file in this field or browse to the file location.

 

Key - Insert the Key name in this field.

Value - Insert the Value name in this field.

 

 

Prompt for Filename

Prompt for Filename prompts the user to select a file during macro runtime by displaying a standard "Find File" dialog box. The file name and path chosen by the user are saved to the variable.

 

Destination Variable

Select a variable to use or create a new string variable.

 

Titlebar

Name the window title of the dialog box that opens. This may include instructions in the title bar for users to follow.

 

 

Hint: Starting the Prompt in a Predetermined Folder

 

When prompting for a file you may want to start the search from a specific folder, rather than starting at Computer, in order to save time. To do this, use the Variable Set String - Set Value Now command and save the starting folder path and a file in that folder to a variable. Use this variable in the Destination Variable field of the Prompt for Filename command.

 

Variable Set String %T[1]% to "C:\Users\Stan Jones\Documents\Insight Software Solutions\Testing\Sample.txt"

Variable Set String %T[1]%: Prompt for a filename

 

In the example above, the search prompt will start in the Testing folder to save time clicking through several other folders to arrive at the starting point you want.

 

 

Prompt for Foldername

Prompt for Foldername prompts the user with a standard "Browse for Folder" dialog box during macro playback. The folder name and path selected by the user are saved to the variable. If that variable is predefined, Macro Express looks to make sure that there are no invalid values in the variable string. The value will only be saved up to the invalid character in the string.

 

Destination Variable

Select a variable to use or create a new string variable.

 

Titlebar

Name the window title of the dialog box that opens. This may include instructions in the title bar for users to follow.

 

 

Hint: Starting the Prompt in a Predetermined Folder

 

When prompting for a folder you may want to start the search from a specific folder, rather than starting at Computer, in order to save time. To do this, use the Variable Set String - Set Value Now command and save the starting folder path to a variable. Use this variable in the Destination Variable field of the Prompt for Foldername command.

 

Variable Set String %Folder[1]% to "C:\Users\Howard\Documents\Insight Software Solutions\Macro Express"

Variable Set String %Folder[1]%: Prompt for a foldername

 

In the example above, the search prompt will start in the Macro Express folder to save time clicking through several other folders to arrive at the starting point you want.

 

 

Set to a Random Letter

Set to a Random Letter randomly selects a letter of the alphabet and saves the result to a variable.

 

Destination Variable

Select a variable to use or create a new string variable.

 

 

Set from Environment Variable

Set from Environment Variable obtains a value from an environmental variable and places it into a Text String variable. The complementary command to write a text value to an environmental command may be found in the Variable Modify String window.

 

Destination Variable

Select a variable to use or create a new string variable.

 

Environment Variable

Select the Environmental Variable by clicking on the Variables button or type the variable name in the edit field.

 

 

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 ---

 

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.