Jump to content
Macro Express Forums

Using Run Macro in Variable


Recommended Posts

This one's got me stumped also.

 

I'm using Macro Express Pro 4.3.0.1. and am trying to get the Run Macro in Variable option to work. Tried the example in the helpfile and manual, but I'm always either getting an error that the variable is of the wrong type, or Macro Express crashes literally. Also tried an example which I found on the website, which also crashes Macro Express Pro,

 

http://www.macros.com/usermacs/umrunmacroinvariable.htm

 

My OS is windows 2000 SP4.

 

-Does anybody know of a good guide, example or other which might give me a kick in the right direction on understanding?

 

Thanks for any input on this.

 

Best regards,

Link to comment
Share on other sites

Those samples are ME3 so I could imagine the conversion might not work properly.

 

How about you start by telling us what you are trying to do. I find that most people think they need this command when in deed they do not. Also give us a sample command so we don't have to hunt around. I have W2K machines I can test this on if you give me a command.

 

The help file seems to say it all to me. Essentially whatever the real command string, as you see it in the direct editor, you can create dynamically.

 

Don't forget to report crashes to ISS and also that you can call them for support.

Link to comment
Share on other sites

Not long after MEP was released, I complained about the rotten implementation of the Run Macro in Variable command which had worked so successfully in ME3.

Variable handling hardly works, since MEP has no ability to decide what type a variable is, though I seem to remember that %t[n]% formats may work OK. I can no longer remember the details, but I decided that this command obviously proved far too hard for Insight - I don't know why they ever included it in MEP.

In days of yore, I co-authored a macro library for ME3, which depended heavily on this command.

Link to comment
Share on other sites

@Cory,

 

Thanks for the reply.

 

The idea behind this is trying to put all small sub macros I use to recalculate something, remove something from a sentence, or other, in Run Macro in Variable commands. This assures that I do have everything for a macro, in that macro, and do not need to think of possible sub macros needed for it to work properly.

 

For now I do not have something definitive, as I'm not even able to make the sample provided in my 1st post, or the sample on page 422 of the user guide (Run Macro in Variable section in the help file) to work properly.

 

Sure, I'll report crashes to ISS, but 1st I need to find out if it's me being dumb and not understanding it, or if it's Macro Express Pro not doing what it's supposed to.

 

Error I get when trying the example from the user guide:

post-4537-0-35788900-1328079520_thumb.jpg

 

Error I get when using the example from the website, http://www.macros.com/usermacs/umrunmacroinvariable.htm :

post-4537-0-68839300-1328079551_thumb.jpg

 

 

@Paul,

Thanks again for the reply and the heads up.

 

It leaves me to believe that this one might indeed be a shortcoming of Macro Express Pro. I'll try some more using your tip of NOT using named variables in the Run Macro in Variable commands to see if that might be a workaround/solution.

 

If I find positive results, I'll post back here.

 

 

Thanks both Paul and Cory for your replies on both my questions. Much appreciated.

 

Best rregards,

 

PS: The screen dumps attached are made using the XP machine and trial from Macro Express Pro. I'll see again this evening using my own windows 2000 SP4 machine.

Link to comment
Share on other sites

[sigh] Yes we know the Run Macro in Variable crashes with the example. It crashes for me too. And it shouldn't but I'm sure we have all bugrep at this point. Let's move past that.

 

Provide an example created in MEP that crashes. Something you're trying to accomplish. I know the command at least runs some of the time. See the example below which will perform a beep.

 

Visible:

Variable Set String %Beep% to "<BEEP/>"
Run Macro in Variable: %Beep%

Direct:

<VARIABLE SET STRING Option="\x00" Destination="%Beep%" Value="<BEEP/>" NoEmbeddedVars="FALSE"/>
<RUN MACRO IN VARIABLE Variable="%Beep%"/>

Link to comment
Share on other sites

I'll try some more using your tip of NOT using named variables in the Run Macro in Variable commands to see if that might be a workaround/solution.

 

If I find positive results, I'll post back here.

I don't think you will find any positive results.

I've just been playing with this some more.

I have this macro, that returns the current time of day in seconds since midnight.

<VARIABLE SET INTEGER Option="\x13" Destination="%N[1]%"/>
<VARIABLE SET INTEGER Option="\x14" Destination="%N[2]%"/>
<VARIABLE SET INTEGER Option="\x15" Destination="%N[3]%"/>
<VARIABLE MODIFY INTEGER Option="\x02" Destination="%N[1]%" Value1="%N[1]%" Value2="3600"/>
<VARIABLE MODIFY INTEGER Option="\x02" Destination="%N[2]%" Value1="%N[2]%" Value2="60"/>
<VARIABLE MODIFY INTEGER Option="\x00" Destination="%N[1]%" Value1="%N[1]%" Value2="%N[2]%"/>
<VARIABLE MODIFY INTEGER Option="\x00" Destination="%N[99]%" Value1="%N[1]%" Value2="%N[3]%"/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %n[99]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

When run, this returns 8498 when the time is approximately 02:21

But I cannot persuade it to return anything other than 0 when run within a macro (remembering to replace all % signs in the variable being set to {%}, and to include the NoEmbeddedVars="FALSE" command in each line, as per the Help).

<VARIABLE SET STRING Option="\x00" Destination="%tMacroCode%" Value="<VARIABLE SET INTEGER Option=\"\\x13\" Destination=\"{%}N[1]{%}\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x14\" Destination=\"{%}N[2]{%}\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x15\" Destination=\"{%}N[3]{%}\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"{%}N[1]{%}\" Value1=\"%N[1]%\" Value2=\"3600\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"{%}N[2]{%}\" Value1=\"%N[2]%\" Value2=\"60\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"{%}N[1]{%}\" Value1=\"%N[1]%\" Value2=\"%N[2]%\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"{%}N[99]{%}\" Value1=\"%N[1]%\" Value2=\"%N[3]%\" NoEmbeddedVars=\"FALSE\"/>\r\n<TEXT BOX DISPLAY Content=\"{\\\\rtf1\\\\ansi\\\\ansicpg1252\\\\deff0\\\\deflang3081{\\\\fonttbl{\\\\f0\\\\fnil\\\\fcharset0 Tahoma;}{\\\\f1\\\\fnil Tahoma;}}\\r\\n\\\\viewkind4\\\\uc1\\\\pard\\\\f0\\\\fs16 %n[99]%\\\\f1 \\r\\n\\\\par }\\r\\n\" Left=\"Center\" Top=\"Center\" Width=\"278\" Height=\"200\" Monitor=\"2\" OnTop=\"FALSE\" Keep_Focus=\"TRUE\" Mode=\"\\x00\" Delay=\"0\"/>" NoEmbeddedVars="FALSE"/>
<RUN MACRO IN VARIABLE Variable="%tMacroCode%"/>

 

Update 10 minutes later

OK, the Help file sprouts garbage! I got this to work as follows:

- ignore the {%} Help statement, and omit the NoEmbeddedVars="FALSE" statement

- instead, simply copy the desired commands, and tick the Don't process embedded variables tick box

<VARIABLE SET STRING Option="\x00" Destination="%tMacroCode%" Value="<VARIABLE SET INTEGER Option=\"\\x13\" Destination=\"%N[1]%\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x14\" Destination=\"%N[2]%\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x15\" Destination=\"%N[3]%\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"%N[1]%\" Value1=\"%N[1]%\" Value2=\"3600\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"%N[2]%\" Value1=\"%N[2]%\" Value2=\"60\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"%N[1]%\" Value1=\"%N[1]%\" Value2=\"%N[2]%\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"%N[99]%\" Value1=\"%N[1]%\" Value2=\"%N[3]%\"/>\r\n<TEXT BOX DISPLAY Content=\"{\\\\rtf1\\\\ansi\\\\ansicpg1252\\\\deff0\\\\deflang3081{\\\\fonttbl{\\\\f0\\\\fnil\\\\fcharset0 Tahoma;}{\\\\f1\\\\fnil Tahoma;}}\\r\\n\\\\viewkind4\\\\uc1\\\\pard\\\\f0\\\\fs16 %n[99]%\\\\f1 \\r\\n\\\\par }\\r\\n\" Left=\"Center\" Top=\"Center\" Width=\"278\" Height=\"200\" Monitor=\"2\" OnTop=\"FALSE\" Keep_Focus=\"TRUE\" Mode=\"\\x00\" Delay=\"0\"/>" NoEmbeddedVars="TRUE"/>
<RUN MACRO IN VARIABLE Variable="%tMacroCode%"/>

Notes

1. The final display command can either be part of the code stored in the variable or run after the macro variable has been run, because the value %n[99]% is not out of scope once the macro variable has been run - its value is retained.

2. I changed all the %n[x]% references to %an[x]%, declared variable %an% as an integer array of 99 elements making it available to macros, and, to my amazement, the code worked. So it looks as if Insight has done a lot of work in this area, almost none of which has ever been described in any of their documentation accompanying each new release.

 

To sum up: it looks as if user variable names are fine as long as they are predefined in the macro that runs the macro variable command. Further, variables persist even after the variable macro has run. I take my hat off to Insight for this - 'tis a shame about the lack of documentation.

Link to comment
Share on other sites

A macro written for Macro Express 3 that uses the Run Macro In Variable will not work if imported into Macro Express Pro without changes. The reason is that the syntax of the macro commands is significantly different between Macro Express 3 and Macro Express Pro. The Requirements paragraph of the Run Macro in Variable to Convert a Date web page has been updated to say this. We apologize for the confusion.

 

Paul is correct that using variables in the Run Macro In Variable command in prior versions was very difficult (nearly impossible). Changes in Macro Express Pro v 4.3.0.1 added features that fix those difficulties. The changes to the Run Macro In Variable command are described in the July 7, 2011 edition of the Macro Express News.

Edited by kevin
add "variables in" in second paragraph
Link to comment
Share on other sites

@Paul,

Thanks for the help, and the GREAT EFFORT you took in trying to get it to work. It's all clear to me now, so from this point I can start trying to make this work with the macro's I create myself.

 

@Kevin,

Thanks for pointing to the newsletter, as I'd only been looking at the user guide, webpage example, forum, and various places on the internet.

 

The last 3 paragraphs of the newsletter on this command hit it home for me, and made me see the reasoning on the "Expansion of Variables ABC" example as found in the user guide. This "Expansion of Variables ABC" example had confused me.

 

Pardon the forwardness, but maybe an idea to add those 3 paragraphs as an additional note to the "Run Macro in Variable" section of the user guide and help file

 

Best regards,

 

 

EDIT:

I know it's in there, but just for others that may ever find this, as the newsletter information hit it home for me.

 

Page 422/423 revised by me, the section explaining the "Run Macro in Variable" command.

MEPhelp_RunMacroInVariable_Editted.pdf

Link to comment
Share on other sites

Ideally I believe a program should never crash. Ever. However this command is inherently dangerous and syntax checking is impossible since it will not be known until run-time. And a user can put anything in there so it's rather difficult for them to anticipate all of an infinite set of woes. If they were MS with thousands of software engineers I would expect it to work but I'm giving them a little leeway on this one. I consider this a "Use at your own peril" command.

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.

Guest
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.

Loading...
 Share

×
×
  • Create New...