Jump to content
Macro Express Forums

Global and Local variable illustrations


Recommended Posts

I wanted to help folks visualize the whole global and local nature of variables so I created this page. I didn't spend much time on it but I was wondering if folks could critique.

Link to comment
Share on other sites

I wanted to help folks visualize the whole global and local nature of variables so I created this page. I didn't spend much time on it but I was wondering if folks could critique.

 

Hey, Cory, great stuff! :)

 

At a brief glance that seems like it's going to be valuable. This is a 'Bank Holiday Weekend' here so husband duties will keep me away from the PC for a couple of days. But I'll study it properly as soon as I get the chance. Might even try a few experimental macros!

 

Thanks for putting in the time and effort to prepare this nice looking page. Maybe ISS can incorporate some of it in the Help?

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

How deep can a global variable go? If the 'Main' macro call 'Sub1' then 'Sub1' calls 'Sub2' does you example still apply?

Yes, a global variable is available to the macro it is defined in and all macros called (via Macro Run) below it. The only exception to this is if in a called macro a local variable is defined with the same name as the global variable then that macro will use the local variable instead of the global variable.

Link to comment
Share on other sites

Yes, a global variable is available to the macro it is defined in and all macros called (via Macro Run) below it. The only exception to this is if in a called macro a local variable is defined with the same name as the global variable then that macro will use the local variable instead of the global variable.

The other exception is that the calling macro must wait for the called macro to terminate, otherwise the concept of global variables becomes meaningless.

Link to comment
Share on other sites

The other exception is that the calling macro must wait for the called macro to terminate, otherwise the concept of global macro becomes meaningless.
If you read at the bottom of my page I make exactly this point. I used to argue that they were truly global vars but I proved myself wrong.
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...