Jump to content
Macro Express Forums

Run Macro In Variable


Recommended Posts

Is the idea of Run Macro in Variable to literally have a variable played literally as a line of the macro code? If not please explain. I read Joe's book on it and the help file but I'm thick.


Also what would one want to use this for? Wouldn't "IF" statements work just as well?

Link to comment
Share on other sites

The Run Macro in Variable command allows you to create a dynamic macro. That is, a macro that can modify itself depending on other conditions. The example I used to use, until v 3.5d, was to accomplish what you asked in another post ... to have a variable reference other variables. In v 3.5d you can enable the Variable Evaluation Level and then use %T%N1%% but in prior versions that sort of thing required running the macro in a variable.


For example, the command to copy variable T10 to T1 looks like this (in the Direct Editor):


If you wanted to copy T11 to T1 it would look like this:


Notice the :01:10: vs :01:11:. So, you could have your macro determine which variable to copy to and from, put <TMVAR2:09:01:10:000:000:> into variable T2 while altering the :01:10: part to reflect the appropriate variables, and then use the Run Macro in Variable to actually run it. The macro would adjust itself.


Yes, it is true, that in a lot of cases you could just do a bunch of If statements to accomplish this. However, I have run across several examples where that is not possible (I wish I could remember the specific cases other than having one variable reference another). Using this technique can result in much smaller macros.


We have had many requests to have a variable reference another variable. This has always been possible using the Run Macro in Variable command. But, for this specific case, it is no longer necessary if you enable the Variable Evaluation Level feature.

Link to comment
Share on other sites

Well that was exactly why I was asking. It appeared to be the only documented way of doing it. I'm very happy I won't have to learn this as I'm sure I could get myself in big trouble doing it!



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...