terrypin Posted August 15, 2019 Report Share Posted August 15, 2019 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? Quote Link to comment Share on other sites More sharing options...
Samrae Posted August 15, 2019 Report Share Posted August 15, 2019 Make sure they are defined in both macro A and macro B and that they are set as Global variables in both. Quote Link to comment Share on other sites More sharing options...
terrypin Posted August 15, 2019 Author Report Share Posted August 15, 2019 @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. Quote Link to comment Share on other sites More sharing options...
acantor Posted August 15, 2019 Report Share Posted August 15, 2019 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!!! Quote Link to comment Share on other sites More sharing options...
terrypin Posted August 15, 2019 Author Report Share Posted August 15, 2019 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. Quote Link to comment Share on other sites More sharing options...
terrypin Posted August 16, 2019 Author Report Share Posted August 16, 2019 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. Quote Link to comment Share on other sites More sharing options...
acantor Posted August 16, 2019 Report Share Posted August 16, 2019 Hi Terry, Glad you got it sorted. It's curious how many macro scripting issues can only be resolved through perseverance! Quote Link to comment Share on other sites More sharing options...
Cory Posted August 16, 2019 Report Share Posted August 16, 2019 For anyone wondering about variable scope, click here to see my explanation. Quote Link to comment Share on other sites More sharing options...
acantor Posted August 17, 2019 Report Share Posted August 17, 2019 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. Quote Link to comment Share on other sites More sharing options...
Cory Posted November 5, 2019 Report Share Posted November 5, 2019 You're welcome Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.