|
Variable and Expression
Variable
Variable is a symbol that stands for a value. For example, in the expression
x+y+10
x and y are variables, and 10 is a constant. Variables can represent numeric values, character strings, date time or other data type.
Variables play an important role in Macro Expert because they enable you to create flexible macros. Rather than entering data directly into a script, you can use variables to represent the data. Then, when the macro is played, the variables are replaced with real data. This makes it possible for the same macro to process different sets of data. For example, you might want to use the action "Mouse Move" for placing the mouse pointer at a position, and the position should be determined when the macro is played. You can use the variable to represent the coordinates value of the position. Depending on the value of variable, the mouse pointer will be placed at the different position.
Every variable has a name, called the variable name, and a data type. A variable's data type indicates what sort of value the variable represents. Macro Expert supports 4 data types, String, Number, Datetime and Binary
data. The binary data is used to the instruction "Call an External DLL".
In Macro Expert, there are two type variables, the global variables and local variables. The
global variables are predefined by the software for holding those general content, such as the
current time, Windows Directory and etc.. The local
variables are restricted to a single macro. This means that you cannot access the variables
from a different macro. For more information about working with the local variables, please click here.
- String
Holds sequences character code which represents a single character. The string data type supports + operator and - operator.
Example A:
"abc"+"bcd"
' The preceding expression evaluates to "abcbcd".
Example B:
"abcd"-"bc"
' The preceding expression evaluates to "ad".
In an expression, the string data should be quoted by the single or double quotation marks. You may use \' to represent
the single quotation sign, and use the \" to represent the double quotation sign. For example,
Example A:
'He\'s a student.'
' The preceding expression evaluates to "He's a student.".
Example B:
"He said: \"No\""го
' The preceding expression evaluates to "He said: "No"".
- Number
Holds signed IEEE 64-bit (8-byte) double-precision floating-point numbers ranging in value from -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values and from 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values. Double-precision numbers store an approximation of a real number.
The number data type supports + operator, - operator, * operator, / opeartor and \ mod operator. For example,
Example A:
1+20
' The preceding expression evaluates to "21".
Example B:
0x10 \ 3
' The preceding expression evaluates to "1".
In an expression, you may use the hexadecimal notation to represent a number, for example, 0x2A.
- Datetime
Holds date and time values. The datetime supports + operator, - operator, * operator, / opeartor.
Example A:
#2007-08-10#+1
' The preceding expression evaluates to 2007-08-11.
Example B:
#2007-08-10#-8
' The preceding expression evaluates to 2007-08-02.
In an expression, the datetime content should be quoted by the number sign #.
- Binary
Holds the binary data of any kind. This data type is used to represent a structural data for the instruction "Call an External DLL".
For reading the content in a binary data, you could use the instruction "Advanced Get Variable Value".
Expression
An expression is a series of value elements (variables or constants) combined with operators, which yields a new value. The operators act on the value elements by performing calculations, comparisons, or other operations.
- Operator
An operator is a code element that performs an operation on one or more value elements that hold values. Value elements include variables, constants, returns from Function and Operator procedures, and expressions.
Macro Expert supports +, -, *, /, \(mod) and () operator, and it will convert the right value element to the appropriate data type before performing the operation, as the following example demonstrates.
%="abc "+20.03%
' The preceding expression evaluates to "abc 20.03".
%=20.03 + "abc"%
' The preceding expression evaluates to 20.03.
%=20.03 + "5abc"%
' The preceding expression evaluates to 25.03.
- Using Expression
To use an expression, simply quote the expression by percentage signs, and use the equal mark to lead, like this:
%=1+2%, or %=5 * VARIABLENAME% (substitute VARIABLENAME for the variable name you used.)
The equal mark could be ignored if the expression does not include the operator, for example, %VARIABLENAME%.
- Special character
Percentage sign %
Uses the \% to represent the percentage sign in an expression. For example, %="100\%"+"abc"%.
New line sign
Uses the \n to represent the new line sign in an expression. For example, %="100\n"+"abc"%.
Tab character
Uses the \t to represent the horization tab character in an expression. For example, %="100\tabc"%.
Note:
New line sign and Tab character are available only in the experssion.
Note:
The number datatype in memory is same as the double-precision floating-point numbers.
The datatime datatype in memory is same as the struct SYSTEMTIME in Windows API.
Not all parameters of actions support the expression. If you could see the icon on the right of the parameter field in the instruction parameters dialog, then the parameter supports the expression.
|