About Variables
Variables and conditions add an intelligence element to macros. They also bring an added level of power. Variables provide the capability that software developers find when writing software programs. However, variables in Macro Express are integrated into the commands so that they are easy to implement and use.
A variable is simply something that holds a value. The value can be changed and modified. In other words, it is variable because it can be anything.
Variables allow input of data into the macro from a variety of sources such as from the macro itself, a file, user input, the Windows clipboard, a .INI file, the title of a window and many others. The variables can then be manipulated, processed and tested. Actions can be taken on the results of the test or on the variables themselves. Some specific examples are provided in this section to help cement the idea behind the use and power of variables.
Types of Variables
Macro Express supports several different types of variables. These are Text, Integer, Large Integer, Decimal, Control, Date/Time, Boolean and Handle variables. Variable names may be up to 31 characters in length.
Variable Type |
Description |
Text String |
Holds any type of character, number, word, phrase or paragraph. |
Integer |
Stores a whole number - values that do not contain fractions (... -2, -1, 0, 1, 2 ...).
An integer variable value can range from –2147483648 to 2147483647. When the value exceeds 2147483647, it ‘wraps’. If an integer variable contains 2147483647 and you add 1 to it, the integer variable will contain –2147483648. |
Large Integer |
Large Integers also store whole numbers.
A large integer variable value can range from -9223372036854775808 to 9223372036854775807. When the value exceeds 9223372036854775807, it ‘wraps’. If an integer variable contains 9223372036854775807 and you add 1 to it, the integer variable will contain –9223372036854775808. |
Decimal |
Holds any type of number, such as 12.432 or -1.3.
A decimal variable value can range from 5.0 x 10^ -324 to 1.7 x 10^308 with 15 to 16 significant digits. This first example is a decimal expanded to include 324 leading zeros followed by the number 5, represented as .000(321 more zeros)5. The second range extends to 17 followed by 308 zeros which would look like 1700000000(300 more zeros).0. The numbers are rounded to 15 or 16 significant digits. |
Control |
Captures information from a window control, such as an edit box, window title, button, etc. This information can then be manipulated to work with other variables in Macro Express. |
Date/Time |
Contains a date in a specific format so that it can be used for date or time calculations. If only needing to insert the date or time into an application without doing any calculations, then use a Text String variable. |
Boolean |
Stores either one of two values: true or false. |
Handle |
Saves the window or control handle information to this variable type. |
Examples of using variables There are virtually an unlimited number of uses for variables in macros. Here are a few examples.
1. Load the mouse cursor position into variables at the beginning of a macro. Restore the mouse location at the end of a macro.
2. Load the position and size of a window into variables at the beginning of a macro. Restore the size and position after manipulating the window.
3. Prompt the user for information and load the information into variables. Save the information to a file and send it via email.
4. Processing a text file or processing an ASCII delimited text file saves values in the files to variables. These values can then be inserted into other applications.
5. Prompt for a text variable. Create boilerplate text that uses the text variable (such as a name) throughout the boilerplate text to customize it. Paste the text into an application.
6. Process a whole set of files by loading in the file names from a text file (i.e. use the process text file command).
7. Manipulate text strings, such as extracting the last 10 characters from a string, finding all characters before the @ symbol, etc. |