Creating a new variable
To create a new variable in the Macro Editor, first click the
<new
variable>
entry at the end of the Variable listbox. The Macro
Editor creates a new variable and assigns to it some initial characteristics
that you should modify to fit your needs. The initial values are:
- An initial name (such as
$a1$
). - An initial type (
string
). - An initial value, which depends on the type (see Default initial values for variables).
- In the Name input field, type the name
$intScreenCount$
. - In the Type listbox, select the
integer
data type. - In the Initial Value field, type 1.
Besides the Variables tab, the Macro Editor provides access, in
several convenient locations, to a popup window for creating new variables.
For example, in the Variable update action, the Name listbox contains
not only all the names of variables that you have already created
but also a <New Variable>
entry. Click this entry to
bring up the popup window for creating a new variable. Variables created
using this popup window are equivalent to variables created in the
Variables tab.
In the Code Editor, you create a new variable using a <create>
element. There is a containing element called <vars> that contains
all the variables in the macro script, and there is a <create>
element for each variable. Sample <vars>
element shows
a <vars> element that contains five <create> elements:
In the figure above the
<vars>
element creates
one variable from each of the standard data types (string, integer,
double, boolean, and field). You should notice that the attributes
of each <create> element match the fields on the Variables tab:
the name attribute contains the variable name,
the type attribute contains the type, and the value field contains the initial value.You must put all variable creations (<create> elements) inside the <vars> element. The <vars> element itself must appear after the <import> element, if any (see the next section), and before the first macro screen (<screen> element).