Defining Variables

 

There are numerous commands that may be used to define an initial value for a variable. See the Variable Set String, Variable Set Integer and Variable Set Decimal commands, or any number of variable set functions. In addition, variables can be set using the date, time, encrypted text, repeats, processing a text file, processing an ASCII delimited text file macro and practically every other command.

 

There are also methods available to modify or manipulate the variables once they have been created. See the Variable Modify String, Variable Modify Integer and Variable Modify Decimal commands, or other variable modify functions.

 

 


 

 

Assign a unique name to each variable or use the variable numbering system from previous versions of Macro Express. The predefined variables are T[1] - T[99] for Text variables, N[1] - N[99] for Integer variables, D[1] - D[99] for Decimal variables and C[1] - C[99] for Control variables.

 

 

Create a New Variable

There are three ways to create a variable to be used in a macro.

 

1. From the Scripting Editor click on the Variables tab. Click on the Add button to open the Variable Properties window and create the variable.

 

 

Step by Step Instructions

This example shows how to create an Integer Variable named Insight with an array of 25 elements.
 

1)From the Script Editor click on the Variables tab to open the Variable Properties window.

2)Enter Insight in the Variable Name field.

3)Click on the drop down menu and select Integer Variable as the Variable Type.

4)Click the check box to create the macro as an array.

5)Enter 25 as the number of elements in the array.

6)Click OK to save and return to the Variables Tab.

7)The new Integer variable, Insight, with 25 elements available is displayed.

 

  

2. When editing a macro command click on the Variables button to the right of the edit field. Click on the Add button to open the Variable Properties window as shown below and create the variable.

 

 

Step by Step Instructions

This example shows how to create a Decimal Variable named Software from within the Variable Set Decimal command. This variable will not include an array.

 

1)From the Script Editor expand the Variables section of commands and double click on Variable Set Decimal to open the Variable Set Decimal window.

2)Select the Set Value Now option.

3)Click on the Variables button to the right of Destination Variable to open the Insert Variable window.

4)Click on the Add button to open the Variable Properties window.

5)Enter Software in the Variable Name field.

6)The Variable Type defaults to Decimal Variables.

7)Click OK to save and return to the Insert Variable window.

8)Click OK to save and return to the Variable Set Decimal window.

9)%Software% should now be listed as the Destination Variable.

    

 

3. In the macro command window enter the name of the variable in an edit field that accepts variables. After clicking OK to save the information in the command window, a prompt informs that the variable does not exist and asks to create it now. Verify that the Variable Type is correct and create as an array, if necessary.

 

 

Step by Step Instructions

This example demonstrates how to create a Text Variable named Solutions, with no array, using the Variable Set String command.
 

1)From the Script Editor expand the Variables section of commands and double click on Variable Set String to open the Variable Set String window.

2)Select the Set Value Now option.

3)Type Solutions in the Destination Variable field.

4)Enter This is a Test in the Initial Value Edit field.

5)Click OK to save the changes.

6)A dialog box opens informing that The variable "Solutions" is not currently defined. Would you like to create it now?

7)Click Yes to open the Variable Properties window.

8)Solutions should be listed as the variable name and Text Variables selected.

9)Click OK to save the variable and return to the Script Editor.

 

 

Variable Name

In the Variable Properties window assign a name to the variable being created. Assign any name to the variable or use the variable assignments defined in previous versions of Macro Express, such as T1 or D95. Macro Express displays them as T[1] or D[95] because they are now part of a variable array.  In the sample image above the variable name is sales. Variable names may not exceed 31 characters.

 

Note: If assigning original names to variables, rather than using T[1], D[1], etc., then the following characters are not allowed in the variable name:  [ ] < > , . - + = \ | / * %

 

 

Variable Type

Select from the drop down list the type of variable to create, such as a Text variable, Integer variable, Decimal variable, etc.

 

 

Create as an Array

At times it may be appropriate to assign more than one value to a single variable. In such instances, create a variable that contains a series of values. This series is called a variable array. If the variable is named "sales", then the array elements would be designated as sales[1], sales[2] and so on up to the number of elements defined in the array. Array elements start with [1] and not [0]. Each element stores a separate value.

 

 

Script Editor > Variables Tab > Add Button

Or Click on any Variables Button next to an Edit Field > Add Button 

 

 

Select the Create as an array option to set the variable as an array and then choose the number of elements to be available in the array. Variable arrays place brackets around the element number of the variable.

 

Elements

Select the number of elements needed in the array. In the example above, 30 elements have been selected. This allows the use of up to 30 variables in the array. The variable format looks like the following:

 

sales[1]

sales[2]

sales[3]

...

sales[30]

 

In the above example, an array with 30 elements allows assignment of a value to variable sales[1], another value to variable sales[2], etc. - up through sales [30]. There is not a limit to the number of elements that may be assigned to an array variable. 

 

Note: The "T", "N", "D" and "C" variables are predefined and always available for use as an array. The variables are assigned as T[1], T[2], T[3], etc. By default, each of these predefined variables are set to an array of 99 variables. There is not a limit to the number of elements in the array and the default arrays may be expanded if desired. Using example #1 above, change the array value. The element of the array is placed in brackets as shown in the Elements example above.

 

 

Make this Variable Available to Macros Called by this Macro

Select this option in order to allow the variable value to be passed between macros when using the Macro Run command or when using the Variable Save and Variable Restore commands.

 

When this option is selected the variables are also referred to as Global variables, because they are available to other macros. When not selected, the variable values are Local and may only be seen in the current macro.

 

Click OK to save the variable information.

 

Note: See the Using Integer Variables and Using Text String Variables tutorials for actual examples of how to create variables and use them in macros.