Carlos Garcia Posted February 21, 2005 Report Share Posted February 21, 2005 Hi, I'm planning for a group of macros to call each other or not in sequence based on certain conditions I don't need to go into. These macros are basically subroutines of a larger task. I have reused much of the "code" from one subroutine to the other. Therefore I need to know if variable "N1" in "Macro_1" is set to "Apples", then Macro_1 calls Macro_2 as it's last instruction before it terminates will the value within "N1" be initialised as "Apples" if this variable is used in Macro_2? In other words to variable values "carry over" into other macros? Needless to say is this happens it's going to be extra work for me... Thanks in advance. Quote Link to comment Share on other sites More sharing options...
joe Posted February 21, 2005 Report Share Posted February 21, 2005 Welcome to the group Carlos! All variables in Macro Express are global in scope. It does not matter in which level within a chain of callable macros the variable is set or reset. All other macros, up-and-down the calling chain will use the same variable and variable value. In other words, you may have an unlimited number of macros calling other macros, but they will all use the same T1-T99, N1-N99, and D1-D99 set of finite variable tags. This will be true for as long as the current macro session is running. Once a new macro session is fired, all variables are immediately set back to their default empty or zero values. A macro session starts when a macro, or chain of macros, begins execution and ends when it, or they, stop. You should look into the native Variable Save and Variable Restore commands. These will allow you to save an instance of a variable before changing it and then restore it back again. If you need to save and restore more than a single instance of a variable, then there are routines available in our PGM Functions Library that will allow you to save and restore up to sixteen levels of variables. Quote Link to comment Share on other sites More sharing options...
Carlos Garcia Posted February 21, 2005 Author Report Share Posted February 21, 2005 I see thank you for the quick post. I will either have to rename varibles so I do not use the same one twice unless I can find some form of "reset all variables to default" type command. Quote Link to comment Share on other sites More sharing options...
kevin Posted February 21, 2005 Report Share Posted February 21, 2005 The "Clear Variables" command allows you to clear variables. Quote Link to comment Share on other sites More sharing options...
Carlos Garcia Posted February 23, 2005 Author Report Share Posted February 23, 2005 Makes sense... I'm such a "noob" 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.