|
Variable
Management
Without variables,
and a way to manage them, Macro Express® would not be an
easy, or for that matter, practical, application to develop
anything with other than simple, basic macros. Somewhere along
the line, as your macros grow in scope and power, you will begin
to use variables. And when you do, you will quickly find that
you need a way to manage and control them.
The native Macro Express variable
environment provides us with 99 variables named T1 through T99
for storing text strings; 99 variables named N1 through N99
for storing integers (whole numbers); and 99 variables named
D1 through D99 for storing doubles (decimal type numbers). It
also provides an additional 99 variables named C1 through C99
for storing Window Control variables and an unlimited number
of Environment variables, for which you create your own names.
Both of these latter types are specialty variables and are of
no concern to the Variable Management functions.
All three standard variable types
are global in scope, meaning that their values can be changed
from anywhere within your macro. To refresh your memory, a macro
is a collection of one or more functions linked together via
the Macro Run command to perform a specific task. Therefore,
%T1% created in one function can be overwritten by %T1% in a
different function, which can be changed by another function,
ad infinitem. In the native Macro Express variable environment
there is only a single %T1%, %N1%, and %D1% variable to be accessed
by an unlimited number of functions.
Variable Management functions
resolve this issue by allowing you to save and restore up to
sixteen sets of variables at any time without overwriting the
variable set that you are currently using. In other words, you
can have sixteen T1, N1, and D1 variables stored concurrently
in memory. Since Macro Express provides 297 variables, why in
the world would anyone want 4,752 of them? Well, we don't. It
is not the quantity that is important, but rather how the variable
sets themselves are used. Very rarely do we ever use more than
a dozen variables in any one of our functions. But we do use
the same ones over and over again. It is how reusable functions
are created.
Let us say for instance that
we use T9 for the function name in very one of our functions
(and we do). Using the Variable Management functions, we can
have one function call another, which calls, another, and in
turn, calls another
up to sixteen times, or levels deep,
before we run out of T9's. We never again have to worry about
which variable gets used in what function. That is the beauty
of the Variable Management functions.
Combining the Macro Run command,
which is one of the best features of Macro Express, with our
Variable Management functions gives you the power to create
reusable functions that can be called at any time into any macro.
The Variable Management category
is comprised of ten functions, which handle the saving and restoring
of variables to and from the Registry. There are different pairs,
or sets, of save and restore variables for various situations.
The difference between them is only which of the 297 available
variables are dealt with.
{ Variables - Save } Saves all
297 variables T1-T99, N1-N99, and D1-D99
{ Variables - Restore } Restores all 297 variables
{ Variables - Save SI } Saves all 198 string and integers T1-T99
and N1-N99
{ Variables - Restore SI } Restores all 198 string and integers
{ Variables - Save 25 } Saves the first 25 of all types T1-T25,
N1-N25, and D1-D25
{ Variables - Restore 25 } Restores the first 25 of all types
{ Variables - Save DT } Saves the first 25 string and integers
T1-T25, N1-N25, D1-D25
{ Variables - Restore DT } Restores the first 25 string and
integers
{ Variables - Reset Registry Values } Resets all variables in
all areas to their default empty values
{ Variables - Reset Current Level } Resets the area pointer
back to zero
Examples
{ Variable Management Example - Decimals }
{ Variable Management Example - Integers }
{ Variable Management Example A }
{ Variable Management Example B }
{ Variable Management Example C }
{ Variable Management Example D }
{ Variable Management Example E }
{ Variable Management Example F }
{ Variable Management Example }
Next: Program
Operations
|