Variable Set Integer

 

This command assigns a value to an integer variable. Once saved to an integer variable, use the Modify Integer Variable commands or others to manipulate the original values.

 

Note: An integer variable (N[1], etc.) can range from –2147483648 to 2147483647. When the value exceeds 2147483647, it ‘wraps’. If an integer variable contains 2147483647 and 1 is added to it, the integer variable will contain –2147483648.

 

 

Script Editor > Expand Variables Category > Variable Set Integer

 

 

What Method Would You Like to Use?

Select from the drop down list the method required for defining the variable. Each of the options are described below.

 

 

Set Value Now

Set Value Now assigns a value to the variable now. Enter the variable value and save. This value will be used when the macro is run.

 

Destination Variable

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

 

Initial Value

Insert the contents of the variable in this field.

 

 

Prompt for Value

Prompt for Value opens an input box when the macro runs and prompts the user to input an integer value.

 

Destination Variable

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

 

Prompt

Optionally enter text in the Prompt edit field to explain the type of value the user should input. The instructions appear above the input field during macro playback.

 

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 Manually 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 integer value to be set as the default. Then use the Prompt for Value option. Both options must reference the same variable, such as N[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. The number 10 is the default value.

 

Variable Set Integer %N[1]% to 10

Variable Set Integer %N[1]% from Prompt

 

 

Set to the Mouse X Coordinate

Set to the Mouse X Coordinate examines the current mouse position on the screen at macro runtime and places the X pixel coordinate of the mouse position in the variable.

 

Destination Variable

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

 

 

Set to the Mouse Y Coordinate

Set to the Mouse Y Coordinate examines the current mouse position on the screen at macro runtime and places the Y pixel coordinate of the mouse position in the variable.

 

Destination Variable

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

 

 

Set to the Size of a File

Set to the Size of a File examines the size of the file selected. The file size (in bytes) is saved to the variable.

 

Destination Variable

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

 

Filename

Insert the name of the file and path to be examined or click on the Browse button to select the file.

 

 

Set to a Random Value

Set to a Random Value saves a random number to an Integer variable. Select the range of Integer values. If 5 is selected as the minimum value and 99 as the maximum value, then the possible random number may be any integer from 5 to 99.

 

Destination Variable

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

 

Minimum Value

Insert the lowest number that may be included as a possible random number.

 

Maximum Value

Insert the highest number that may be included as a possible random number.

 

 

Set to the Screen

These two options save the width or height of the screen to an integer variable. Select a variable to use or create a new integer variable.

 

Set to the Screen Width

The integer value is set to the width of the screen. The value assigned is the number of pixels in the width of the screen.

 

Set to the Screen Height

The integer value will be set to the height of the screen. The value assigned is the number of pixels in the height of the screen.     

 

 

Set to the Current Window

These four commands examine the current window that has focus and saves values to the variable. Select a variable to use or create a new integer variable.

 

Set to the Current Window's Top

Set to the Current Window's Top examines the window that is currently on top of all others, specifically its location on the screen. This function obtains the top position (in X,Y screen coordinates) of the window and places the value in the variable. Note: Obtain the bottom coordinate of the window by adding the Window Top to the Window Height.

 

Set to the Current Window's Left

Set to the Current Window's Left examines the window that is currently on top of all others, specifically its location on the screen. This function obtains the left position (in X,Y screen coordinates) of the window and places the value in the variable. Note: Obtain the right coordinate of the window by adding the Window Left to the Window Width.

           

Set to the Current Window's Width

Set to the Current Window's Width examines the size of the window that is currently on top of all other open windows. This function obtains the width (in pixels) of the window and places the value in the variable.

 

Set to the Current Window's Height

Set to the Current Window's Height examines the size of the window that is currently on top of all other open windows. This function obtains the height (in pixels) of the window and places the value in the variable.

 

 

Set to the Clipboard Value

Set to the Clipboard Value examines the text contents of the clipboard. It reads this value and strips off any spaces, carriage returns or line feeds. This function then attempts to convert the value to an integer and place it in the variable. If a non integer value (i.e. a string of text) is in the clipboard or the clipboard is empty, the variable value is set to zero.

 

Destination Variable

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

 

 

Set to the Length of a Text Variable

Set to the Length of a Text Variable counts the number of characters in a text string variable and saves that number to an integer variable. For example, if the length of text string variable T[1] is 100 characters, then the value saved to the Integer variable is 100.

 

 

Example

 

This example shows how to obtain the last 14 characters of a text string when the string is of varying lengths.

 

For this example, the text string is saved to variable T[1]. The text string could have been copied to the clipboard and then saved to a variable, extracted from a Text File, input by a user, or any number of ways.

 

1. Variable Set Integer %N[1]% to the length of variable %T[1]%

2. Variable Modify Integer: %N[1]% = %N[1]% - 13

3. Variable Modify String %T[2]% to a substring in %T[1]% starting at %N[1]% and 14 characters long

 

- Step one calculates the length of the text string variable and saves the value to N[1].

- Step two subtracts 13 characters from the length of the string and saves the new value to N[1].

-The last step copies just the last 14 characters of the string and saves the text to a new value of T[2].

 

Destination Variable

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

 

Text Variable

Enter the variable name or select the text variable that is to be examined.

 

 

Set to the Position of Text in a Text Variable

Set to the Position of Text in a Text Variable locates specific text in a text string variable and saves the location (position) to an integer variable.

 

For example, if variable T[1] contained "myemailaddress@myisp.com", this command could find the location of the @ symbol in the string. The integer variable would be set to 15 as @ is the 15th character. This information could then be used to delete or copy all of the text found before the @ symbol, or after.

 

Note: If the text string cannot be found during playback of the macro, the position is set to (0) zero.

 

Also look at the Split String command for another text string manipulation option.

 

 

Example

This example shows how to save all characters before the @ symbol to a new text string variable when the string is of varying lengths. If the text string was always the same length, you would just use the Copy Part of Text option from the Variable Modify String command.

 

For this example, the text string is saved to variable T[1]. The text string could have been copied to the clipboard and then saved to a variable, extracted from a Text File, input by a user, or any number of ways.

 

1.Variable Set Integer %N[1]% to the position of "@" in %T[1]%

2.Variable Modify Integer: %N[1]% = %N[1]% - 1

3.Variable Modify String %T[2]% to a substring in %T[1]% starting at 1 and %N[1]% characters long

 

-Step one calculates the position of the @ symbol in the text string variable and saves the value to N[1].

-Step two subtracts one character from the length and saves the new value to N[1].

-The last step copies all of the characters before the @ symbol and saves the text to a new value of T[2].

 

 

Destination Variable

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

 

Text Variable

Enter the variable name or select the text variable that is to be examined.

 

Text to Search For

Enter the text that you want to find in the variable you have selected.

 

Ignore Case Sensitivity

Select this option if you want to ignore upper or lower case letters in the string.

 

 

Set Value to Date or Time

These seven Date or Time functions set a value to the variable based on the date or time of the computer's system clock. If the system clock is incorrect, the integer values will also be incorrect.

 

An example of using one of these options would be the Set Value From Current Hour. The macro could play one set of instructions if the system clock reads before 5:00pm or play back another set of instructions if the system clock reads after 5:00pm.

 

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

 

Set to the Current Day

Set to the Current Day sets the integer value based on the current date. A value of 1 to 31 is saved to the variable.

 

Set to the Current Month

Set to the Current Month sets the integer value based on the current month. A value 1 to 12 is saved to the variable.

 

Set to the Current Year

Set to the Current Year sets the integer value based on the current year. The value is saved as a four digit number.

 

Set to the Current Day of Week

Set to the Current Day of Week sets the integer value based on the current day of the week. The day of the week is an integer between 1 and 7. Sunday is the first day (i.e. 1) of the week and Saturday is the seventh (i.e. 7).

 

Set to the Current Hour

Set to the Current Hour sets the integer value based on the current hour. The hours are set in military time. For example, 5:00pm would be set as 17:00, or 8:00am would be set as 8:00. The integer variable is saved as 17 for 5:00pm or 8 for 8:00am. 

 

Set to the Current Minute

Set to the Current Minute sets the integer value based on the current minute. A value of 0 to 59 is saved to the variable.

 

Set to the Current Second

Set to the Current Second sets the integer value based on the current second. A value of 0 to 59 is saved to the variable.

 

 

Set to Control

These four commands are similar to the Set Value to the Current Window commands. But rather than look at the current window, these commands set the value from a specific control.

 

Controls refer to the identifiable parts of a specific application window. Controls may include such things as a button, an edit box, a toolbar, a window title bar or other items. The control may be part of the main application window or be part of a child window (a window within a window). Depending on how the application was written, the entire window may be a single control.

 

Set to a Control's Left

Set to a Control's Left examines the location on the screen of the selected Control. This function obtains the left position (in X,Y screen coordinates) of the Control and places the value in the variable.

 

Note: Find the right position of the Control by adding the Control Left to the Control Width.

 

Set to a Control's Top

Set to a Control's Top examines the location on the screen of the selected Control. This function obtains the top position (in X,Y screen coordinates) of the Control and places the value in the variable.

 

Note: Find the bottom position of the Control by adding the Control Top to the Control Height.

 

Set to a Control's Width

Set to a Control's Width examines the size on the screen of the selected Control. This function obtains the width (in pixels) of the Control and places the value in the variable.

 

Set to a Control's Height

Set to a Control's Height examines the size on the screen of the selected Control. The function obtains the height (in pixels) of the Control and places the value in the variable.

 

 

Computer Monitor

These monitor options obtain the width or height of a monitor in pixels, as well as determine the active monitor or the number of monitors in use. Then use the If Variable command to take specific actions based on the variable results.

 

Set to a Monitor's Width

Save the width of the monitor in pixels to an Integer variable. If using a single monitor, then insert 0 (zero) as the monitor number. If multiple monitors are connected to the system, then insert 0 as the first monitor, 1 (one) as the second monitor, 2 (two) as the third monitor, etc.

 

Set to a Monitor's Height

Save the height of the monitor in pixels to an Integer variable. If using a single monitor, then insert 0 (zero) as the monitor number. If multiple monitors are connected to the system, then insert 0 (zero) as the first monitor, 1 (one) as the second monitor, 2 (two) as the third monitor, etc.

 

Set to Number of Monitors

Determine the number of monitors attached to the system and save the value to an Integer variable. So, for example, if there are three monitors attached to the computer, then the Integer variable value would be 3.

 

Set to Active Monitor

This option saves the value of the active monitor (whichever monitor has focus) to an Integer variable. The values are similar to the monitor numbers mentioned above. The first monitor receives a value of 0 (zero). A second monitor receives a value of 1 (one), the third monitor 2 (two), and so on.

 

 

Get the Idle Time

Get the Idle Time calculates the computer idle time and saves the value to a variable. The idle time is specified as no mouse or keyboard activity occurring. The amount of time since the last mouse event or keyboard activity is saved to the Integer variable. The value is saved in time increments of seconds.

 

 

Desktop

These two desktop options obtain the width or height in pixels of the entire desktop, which may span more than one monitor. Macro Express retrieves the desktop size from what Windows reports as the desktop.

 

Set to Desktop Width

Save the width of the desktop in pixels to an Integer variable.

 

Set to Desktop Height

Save the height of the desktop in pixels to an Integer variable.