Sample Macro

Variable Evaluation Level

Written by Kevin Heaton, Insight Software Solutions, Inc.

What it does

This macro demonstrates the Variable Evaluation Level. This feature allows for one variable to access another. Consider, for example, the statement:

%T%N1%%

Without the Variable Evaluation Level feature enabled, if N1 contains 10 then the result will be %T10%. But, the content of T10 will not be accessed. The value will remain %T10%.

But, with the Variable Evaluation Level feature, you can tell Macro Express to evaluate each statement that contains a variable multiple times. Thus, in our example, the first evaluation will result in %T10% and a second evaluation will retrieve the content of %T10%.

If N1 contains 1, then this will become %T1%. If N1 contains 99, then this will become %T99%.

To install

Download the macro file umvariableevaluationlevel.mex and save it to your hard drive. Open the macro file or import the macro into your existing macro file by clicking File, Import, Import Macros.

To use

This macro is a sample macro. It demonstrates how to use the Variable Evaluation Level. You can run this macro from within the Macro Express Editor.

To take advantage of the Variable Evaluation Level in in your macros, study this macro to find out how it works and use the techniques in your own macros.

Because the Variable Evaluation Level feature has the potential of breaking existing macros, it is not enabled by default. To enable it, open the program and click on Options, Preferences, Miscellaneous and click on the Advanced button.

Set the Variables Evaluation Level to a number greater than 0. I have mine set to 5 but a value of 2 may be fine for your needs. The value you set determines how many times the variable evaluation is repeated. If you have a complex statement that would require multiple passes to resolve, then you may want to set the Variables Evaluation Level to a larger number. However, problems may occur if you use a very large value.

Requirements

 – Macro Express v 3.5d or later