Jump to content
Macro Express Forums

Global Variable not found in Other Macro

Recommended Posts


I've got MEP and I'm developing for a Citrix environment, so I can't debug easily by inspecting my variable values.


My issue is, when I click on the Variables dropdown in one Macro, I don't see the global variable I defined in another macro that calls this macro in the MEP GUI, and when I try and manually type it in, it's not defined? I don't see the variable %DBN[]% in the Variable dropdown for the MEP Text Type.


Here's my steps:


I'm setting a String Variable from an Excel Spreadsheet clipboard in a macro 'Read Spreadsheet' using the following: [i defined %DBN% as an array variable and the global box is checked. ....[ double-checked.]


Clipboard Copy

Variable Set String %DBN[1]% from clipboard contents

Variable Modify String %DBN[1]%; Strip CR/LF



[i've verified that the correct contents are in the Clipboard by just using a paste into my other program.


Macro Run: Check Eligibility //This is the Macro where I cannot see the global variable



Text Type (Simulate Keystrokes): %DBN[1]%<TAB>



When I try and pull the variable from a list of available variables, none of my global variables are there.






Link to comment
Share on other sites

Nor are they for me in a normal environment. If you think about it for a moment, how could they be?


Let's suppose 3 macros m1, m2 and m3.

m1 defines a global variable v1 and calls m3.

m2 also defines a global variable v2 and calls m3.


If I understand you correctly, you want to see v1 and/or v2 in m3's dropdown list of variables. How does m3 know which global variables it can see? Potentially that is all the variables ever defined by any macro since m3 cannot know what other macros will call it.

Link to comment
Share on other sites

If I interpret your answer correctly, you're just saying my expectations are to high. I thought the whole point of a "global" variable was being able to use it in other macros? How do I get around the MEP GUI that won't give me an option to type it in? Did you look at my example code? How do I work around the GUI? Is there some error in my syntax?

Link to comment
Share on other sites

Did you not read my response? While global variables declared in "parent" macros are indeed available to all called macros at runtime, that does not mean that called macros have any awareness at design time of global variables that may become available at runtime.


I thought the whole point of a "global" variable was being able to use it in other macros?

Yes, you can use it in other variables - at runtime. What you are seeking is the ability to reference such a variable at design time. That's not possible, and I don't see how it ever could be.


Link to comment
Share on other sites

So Paul,

Thank you for your great response to a "design time issue" which does not solve my immediate problem.


How do I call the value "At Runtime" from the parent macro from within the called macro? Can you please look at the code I supplied in my original question and either validate that it is correct or suggest ways to correct it?


Do you have to drop into the other design view in order to be able to save the code "at Design Time?" [since you can't seem to input it through the GUI?]


Thanks again in advance.



Link to comment
Share on other sites

I don't understand what the problem is. In your called macro simply reference the global variable from the calling macro by typing its name directly into the command you're using.

For example, I have test1 and test2 macros, where test1 calls test2 after defining a global variable %tGlobal% as a 5-element string array. test2 simply addresses %tGlobal[1]% to access the 1st element of this array. here's the very simple code:



<VARIABLE SET STRING Option="\x00" Destination="%tGlobal[1]%" Value="This is a global variable" NoEmbeddedVars="FALSE"/>
<MACRO RUN Use_ID="FALSE" Name="Test2" ID="-1" Wait="TRUE"/>



<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 This should show my global variable\r\n\\par \r\n\\par %tGlobal[1]%\\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"/>


This works for me as expected.



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