Jump to content
Macro Express Forums
terrypin

Variables not recognised

Recommended Posts

In macro X I have these commands at the end.

Macro Run: A
Macro Run: B

At the end of macro A several decimal and text variables are displayed correctly.
At the start of macro B they are shown as zero or blank.

I've tried all sorts of stuff over the last hour or so, such as renaming them, rewriting the TBD command, inserting dealys between A and B, restarting ME Pro, kicking the desk, etc. In vain.

I could place a Variable Save and then in B a Variable Restore, but I shouldn't have to do that and I try to avoid those commands.

There are other submacros before A and B, and their variables are being passed without a problem.

Hair pulling time. Anyone have any ideas please?

 

 

Share this post


Link to post
Share on other sites

@samrae

 

Thanks, but they are correctly specified.

 

If I use this macro

// Use F5 after running this to show current state of ALL variables used in this session.
Variable Restore: Restore All Variables

the two variables in question tDeg and dDeg are reported correctly in the Variable window.

 

I've temporarily resorted to Variable Save/Restore, but I won't rest until I fix this.

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

I wrote this simple hotkey activated script nicknamed "A":

 

Variable Set String %Value% to "AAAA"
Text Box Display: %Value% in A
Macro Run: B

<VARIABLE SET STRING Option="\x00" Destination="%Value%" Value="AAAA" NoEmbeddedVars="FALSE"/>
<TEXT BOX DISPLAY Title="%Value% in A" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO RUN Use_ID="FALSE" Name="B" ID="-1" Wait="TRUE"/>

And another script (with no activation) nicknamed "B":

 

Text Box Display: %Value% in B


<TEXT BOX DISPLAY Title="%Value% in B" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

The value of %Value% set in "A" is displayed correctly by "B." So your script should be working, unless something else is going on... and usually, something else is happening!!!

Share this post


Link to post
Share on other sites

Thanks Alan, yes there certainly must be!

 

As mentioned, other submacros in the same main macro are passing on values OK. And I too did a similar simple test like yours, with the expected correct result.

 

I’ll get back on the case tomorrow. It has me completely baffled.

 

I recall similar issues, but they always turned out to be because I hadn’t defined the variables, as @samrae suggested. 

Share this post


Link to post
Share on other sites

Sorted!

 

I had been blindly oblivious to the need for the main macro X to have all variables defined!

 

It is just a series of four Macro Run commands. Each individual submacro M1, M2, A and B creates and uses variables. These get used in successive submacros. All were defined (globally) in their respective submacros. But despite that, two variables dDeg and tDeg created in A were not recognised in B.

 

Perhaps it should have been obvious, but now that I have added dDeg and tDeg to the main macro X, all is well. 

 

Share this post


Link to post
Share on other sites

Hi Terry,

 

Glad you got it sorted.

 

It's curious how many macro scripting issues can only be resolved through perseverance!

Share this post


Link to post
Share on other sites

For anyone wondering about variable scope, click here to see my explanation. 

Share this post


Link to post
Share on other sites
16 hours ago, Cory said:

For anyone wondering about variable scope, click here to see my explanation. 

 

Thank you Cory for making available this very clear explanation.

Share this post


Link to post
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...

×
×
  • Create New...