Jump to content
Macro Express Forums

Add/Modify Variables Accross Multiple Macros


Recommended Posts

Hey all,

 

Maybe this has been discussed (I know versions of problems related to Variable Save/Restore have been), but I think I need a very specific clarification.

 

I have a variable that I originally thought could be established without an array (honestly, I wasn't sure what an array was when I built the macro), and now I have that variable established in about a dozen macros but I want to modify it so that it has an array of [5] (more than I actually need, but now I'm starting to think in the long-run). Do I have to manually go through each of my established macros and modify the properites of that variable in each macro individually, or is there a way to change the variable from the ME Explorer window and have it add/modify the properties of this variable in each macro?

 

Additionally, I'm annoyed by the fact that if Macro A sets variable %AccountNumber% to 1234567890 and then Macro A runs Macro B (which has no use for %AccountNumber% so that variable isn't added to Macro B's "variables list"), and then, after finishing Macro B, Macro A runs Macro C, which does need %AccountNumber, the variable is now empty.

 

It was set in A and C, but since B didn't need it, it wasn't established within B's list, so when Macros A and C come back into play, the variable is now useless. What's the point of having the macro available to be called by other macros called by the macro wherein the variable is established, if it's just going to be nulled out during the play of that particular macro?

 

Ok, so it's annoying, but can be worked around by making sure all the variables set in Macro A before Macro B runs are also added to Macro B's variables list. Kind of a lot of work. Is there any way to copy entire variables lists from one macro to another?

 

I guess what I am really looking for is a way to make it so that when I create a variable in one macro, that variable is automatically added to a list of variables automatically accessible to all other macros (like the default Text/Decimal/Interger variables). Even if "Global" is checked, it still only appears within the macro I created it in.

 

And back to the Save/Restore issue... I'm still unclear how/if this is working correctly. If I set %AccountNumber% in Macro A and save variables after it is set, then use Restore Variables in Macro C before that variable is needed, will it work for me? I know I could test it, but I'm so frustrated with ME Pro right this minute that I've suspended it and don't plan on touching it again for a few hours (I'm sulking) :)

 

Thanks for any help!

Link to comment
Share on other sites

First off you're asking two questions here and that would probably be best in different threads.

 

There is no way to change the definitions globally, you need to edit them one at a time.

 

In your ABC example what are the local and global states? I know it can get confusing but I've been using them for quite a while and they seem to fill my needs perfectly and it seems I'm using them in a similar way that you are.

 

In general the Save/Restore is a one shot swap out. But I think you're trying to use this as a workaround to your problem with global/local variables.

 

Also are you sure the variables are changing like you say? I know there's been a problem with the display of variables in the debugger.

Link to comment
Share on other sites

Hey all,

 

Maybe this has been discussed (I know versions of problems related to Variable Save/Restore have been), but I think I need a very specific clarification.

 

Isn't this the discussion we were having in this thread?

http://pgmacros.invisionzone.com/index.php...pic=3505&hl

In particular see my posts #4 and #9.

 

I'm still not clear about it, as you can see from my comments there.

 

I have a variable that I originally thought could be established without an array (honestly, I wasn't sure what an array was when I built the macro), and now I have that variable established in about a dozen macros but I want to modify it so that it has an array of [5] (more than I actually need, but now I'm starting to think in the long-run). Do I have to manually go through each of my established macros and modify the properites of that variable in each macro individually, or is there a way to change the variable from the ME Explorer window and have it add/modify the properties of this variable in each macro?

 

Additionally, I'm annoyed by the fact that if Macro A sets variable %AccountNumber% to 1234567890 and then Macro A runs Macro B (which has no use for %AccountNumber% so that variable isn't added to Macro B's "variables list"), and then, after finishing Macro B, Macro A runs Macro C, which does need %AccountNumber, the variable is now empty.

 

It was set in A and C, but since B didn't need it, it wasn't established within B's list, so when Macros A and C come back into play, the variable is now useless. What's the point of having the macro available to be called by other macros called by the macro wherein the variable is established, if it's just going to be nulled out during the play of that particular macro?

 

Ok, so it's annoying, but can be worked around by making sure all the variables set in Macro A before Macro B runs are also added to Macro B's variables list. Kind of a lot of work. Is there any way to copy entire variables lists from one macro to another?

 

I guess what I am really looking for is a way to make it so that when I create a variable in one macro, that variable is automatically added to a list of variables automatically accessible to all other macros (like the default Text/Decimal/Interger variables). Even if "Global" is checked, it still only appears within the macro I created it in.

 

And back to the Save/Restore issue... I'm still unclear how/if this is working correctly. If I set %AccountNumber% in Macro A and save variables after it is set, then use Restore Variables in Macro C before that variable is needed, will it work for me? I know I could test it, but I'm so frustrated with ME Pro right this minute that I've suspended it and don't plan on touching it again for a few hours (I'm sulking) :)

 

Thanks for any help!

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

First off you're asking two questions here and that would probably be best in different threads.
I know... when I started it was just one question, but by the time I finished it was two... but related in context. Sorry, and thank you for taking them both on :)

 

There is no way to change the definitions globally, you need to edit them one at a time.
Bummer

 

In your ABC example what are the local and global states? I know it can get confusing but I've been using them for quite a while and they seem to fill my needs perfectly and it seems I'm using them in a similar way that you are.
The default is Global (if I understand correctly), and I never change the default, so I'd have to say Global. If I'm mistaken about the default observation, I'd love some input so I can make it right.

 

In general the Save/Restore is a one shot swap out. But I think you're trying to use this as a workaround to your problem with global/local variables.
I am, indeed. If I save variables before running Macro B (from within Macro A), and then Restore it within Macro C (also run from within Macro A), does that restore the variable for use in Macro C?

 

Also are you sure the variables are changing like you say? I know there's been a problem with the display of variables in the debugger.
I haven't used the debugger in ME Pro, yet. I had honestly only discovered the debugger in ME3 about a month before MEP came out, and didn't find it particularly useful (I usually stick Text Box Displays with the Variables I'm interested in defined in the Display). The Debugger in MEP is far more complex and I haven't bothered messing with it yet.

 

<sigh> I don't know what the problem is anymore. I just built a Macro A B C circuit exactly as the one described previously and it worked fine, even without the variable set within Macro B... and yet, in practice, specifically with an application I use for work, one macro collects an account number from an Access page, stores it to a variable, then runs several other macros - some which need this variable, some that don't - and as long as this variable exists in each macro I don't have any problems, but if it is missing from even one of them, my variable resets to null.

 

Obviously I've missed something. Maybe there is a "Restore" command in one of those macros where the variable itself hasn't been saved. I'm no longer frustrated with MEP as much as I am with myself, now. I guess it's back to the drawing board :)

 

Thanks for all your help.

Link to comment
Share on other sites

First off you're asking two questions here and that would probably be best in different threads.

 

There is no way to change the definitions globally, you need to edit them one at a time.

 

In your ABC example what are the local and global states? I know it can get confusing but I've been using them for quite a while and they seem to fill my needs perfectly and it seems I'm using them in a similar way that you are.

 

Cory,

 

Can I chip in here please, as I'm still as confused as Steve about all this.

 

First, am I right in saying that when you talk about Local and Global variables, the definitions are as follows:

 

Local = Not Global

Global = Checkbox enabled against "Make this variable available to macros called by this macro"

 

If so, then am I right that that phrase describing Global does not mean what it says? As Stan advised in that earlier thread I referenced and as you have just confirmed it does not make it available automatically, which was my original (and I think natural) interpretation. You have to redefine it in every macro you want to use it. As I said in post #9 of that thread: "Which somewhat undermines the value of flexible variable names IMO".

If I've got that right, then in your view is that (the need for redefining in every macro, even after a Variable Restore) deliberate or is it a design flaw?

 

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Scasper,

 

As far as existing macros are concerned, you will have to do it manually. However, there is a simple solution for the future. Whenever you think you might need a variable in other macros, use Save to Environment Variable under Variable Modify String. Such values can then be read into any future macro by Set from Environment Variable under Variable Set String.

 

Did I say this was simple? Well, not quite. You do have to remember to save these variables whenever their values are changed by a macro that you want to allow to change them permanently.

 

These will all be string variables, so if you need other types, you will have to convert them when you read and write them.

 

Of course, you could also achieve the same thing by using a text file, provided you remember the file's name and location. :unsure:

 

Stan (mfseeker)

Link to comment
Share on other sites

Scasper,

 

As far as existing macros are concerned, you will have to do it manually. However, there is a simple solution for the future. Whenever you think you might need a variable in other macros, use Save to Environment Variable under Variable Modify String. Such values can then be read into any future macro by Set from Environment Variable under Variable Set String.

 

Did I say this was simple? Well, not quite. You do have to remember to save these variables whenever their values are changed by a macro that you want to allow to change them permanently.

 

These will all be string variables, so if you need other types, you will have to convert them when you read and write them.

 

Of course, you could also achieve the same thing by using a text file, provided you remember the file's name and location. :unsure:

 

Stan (mfseeker)

Since each individual macro has a Ctrl+R function that allows the ability to replace variables (or essentially anything) within that macro, and to replace all instances of it (which I think is a wonderful function, btw), I was hoping the programmers had made a similar function available to the entire macro explorer as well. I'm just glad it's only a relative handful of macros that I have to make the changes in and not hundreds. And since I've obviously screwed up a number of my macros in other ways, I'm pretty much having to get back into them and re-write them anyway, so as long as I'm there...

 

Thanks for all the help, everybody.

Link to comment
Share on other sites

I'm going to look at this specific case right now for my own enjoyment but before I do let me just say that global variables are, well, global and locals are local. At first I was very confused about this but Chris and I had a great conversation on the Beta forum and I realized it was as simple as that. When it's a global variable it's available to all. If it's a local variable it's available to only that macro and does not affect the global pool. So if I have a variable A and it's global in Macro 1 and I have a variable A in macro 2 and it's local then whatever I do to it in that second macro stays there. For instance I set A in 1 to "Fred" and A to "Jim" in 2 in this scenario then write them so that it has a text box to display A after setting the var in 1 before the run, after the var set in 2, and then when I return to 1 again after the macro run it will go Fred, Jim, and Fred. Note that I only set the name twice yet it reverted to Fred. But having both is a little confusing so what you need to remember that any given macro will look to its local variables first. Here's a quick example:

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

And for macro 2:

<VARIABLE SET STRING Option="\x00" Destination="%A%" Value="Jim"/>
<TEXT BOX DISPLAY Title="Name:" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %A%\\f1  %B%\\f0 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Notice that I also use a global variable B but it is only defined in Macro 1 yet it is availible in macro 2. Does this help?

 

I've suggested to ISS on numerous occasions that someone write up some blurb aboutthese new tools with some explanations like this but I think they have been too busy. I might just have to do it myself.

Link to comment
Share on other sites

Steve I have carefully reviewed your ABC scenario and I think you have something awry with your macro that is leading you to think the local/global nature of variables is somehow wiping out your account number variable. I have created a brief demo to demonstrate:

 

Macro A:

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

 

Macro B:

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

 

Macro C:

<TEXT BOX DISPLAY Title="Account Number" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %AccountNumber%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<VARIABLE SET STRING Option="\x00" Destination="%AccountNumber%" Value="0987654321"/>
<TEXT BOX DISPLAY Title="Account Number" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %AccountNumber%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

A and C have a global variable of %AccountNumber% and B has no variables defined. As you can see running B does not wipe out the variable for C as I suspected. I believe you saw something that has sent you down the wrong path and gotten you confused. Unless of course I've misunderstood the problem and if that is the case perhaps you could create a sample for me to understand the nature of your problem.

Link to comment
Share on other sites

A and C have a global variable of %AccountNumber% and B has no variables defined. As you can see running B does not wipe out the variable for C as I suspected. I believe you saw something that has sent you down the wrong path and gotten you confused. Unless of course I've misunderstood the problem and if that is the case perhaps you could create a sample for me to understand the nature of your problem.
Hi Cory,

 

Thanks for dedicating some time to this problem for me. I came to the same conclusion when I had a free minute (and my frustration had subsided). I ran some tests and found that the problem lies somewhere within Macro B (which actually represents a number of different macros, in practice). At some point in my "B" macros my variable was being restored and saved (or something to that effect - I haven't yet been able to locate the exact problem) as a null value. It's nothing to do with Macro Express, but rather a problem with my coding.

 

I've actually started rebuilding the macros from scratch (it's a basic series of about 10 macros (in ME3), which I'm trying to parse out into about 20 new macros in Pro, utilizing more Macro Run commands (for functions occurring in various macros), as well as concurrent macros.

 

The first time through, I mostly just copied the code from ME3 and pasted into MEP, then started picking through and making changes. I thought that would be easier. It was actually very messy. Building from scratch is time-consuming; but it's cleaner, more educational, more fun, and I know exactly where everything is right now as I build it, rather than trying to remember it from months ago when I first built it in 3.

 

Thanks again for all your insight!

Link to comment
Share on other sites

Yes, recreation is always better but it comes with a cost.

 

Warning: Moving a bunch of code out to with Macro Runs will slow your scripts down. Most cases you will not notice it but if you put 3 macro calls in a huge repeat loop you will notice a difference.

Link to comment
Share on other sites

A and C have a global variable of %AccountNumber% and B has no variables defined. As you can see running B does not wipe out the variable for C as I suspected. I believe you saw something that has sent you down the wrong path and gotten you confused. Unless of course I've misunderstood the problem and if that is the case perhaps you could create a sample for me to understand the nature of your problem.

Hey Cory (and anybody else following this thread),

 

I've found the culprit. The problem is that if Macro A sets a variable, and any of the "called" macros have a "Restore" variable within them,

then the variable set in Macro A gets "restored" back to null (or whatever it was last time a Save Variable was used with that variable).

 

So, if Macro C utilizes information saved to variables in other macros (as is my case), it therefore requires a "Restore" command. Because

that will automatically void the variable set in Macros A and B, I have to make sure a Save Variable is placed at the end of each of Macros A

and B.

 

Seems completely obvious to me now, but I guess I was a little confused by the Global check box. I had presumed that making the

variable global, it would be automatically "saved" for use within called macros... which it is, as long as Restore Variables isn't used.

 

What a relief to finally understand the problem.

Link to comment
Share on other sites

I wonder if you don't really need the save/restore. I know we all do things differently but ever since named variables I haven't seen any need for Save/Restore. Also Save/Restore takes a lot of time. But for me if I have a called macro I usually preface the variable name in that variable so to always be unique in the future. So even if I have a need a "name" variable in both they will be different. IOW Macro 1 has %FullName% and I call macro 2 the name parsing macro it's 'full name' variable might be %np_FullName%. Anyway I just thought I would throw it out for you that you might try and figure out a way not to use the save/restore.

Link to comment
Share on other sites

I wonder if you don't really need the save/restore. I know we all do things differently but ever since named variables I haven't seen any need for Save/Restore. Also Save/Restore takes a lot of time. But for me if I have a called macro I usually preface the variable name in that variable so to always be unique in the future. So even if I have a need a "name" variable in both they will be different. IOW Macro 1 has %FullName% and I call macro 2 the name parsing macro it's 'full name' variable might be %np_FullName%. Anyway I just thought I would throw it out for you that you might try and figure out a way not to use the save/restore.

That's an interesting point.

 

Sadly, I have just run into my original problem again, and there isn't any Save/Restore commands getting in the way... A more

accurate representation of the macro sequence is this:

 

  • Macro A calls Macro B (near the beginning of Macro A)
  • Macro B collects the account number (from an Access database) then returns to Macro A
  • Macro A calls Macro C which accesses a separate application and tries to access the account history (for the account
    established in Macro B ).

I've established Textbox displays at the end of Macro B (showing the account number) and at the beginning of Macro C (display-

ing the account number).

 

The named variable is %acctnumber[1]%. I had added this variable to both B and C, but not to A (as discussed earlier, it

shouldn't be necessary). However, when the macro reached C, the variable was empty again. I had to add the variable to

Macro A in order to get it recognized in C. There was no code between when B returned to A and when C was called that could

account for the variable being lost.

 

As I test it, I see that if Macro B calls Macro C, the contents of the variable are not lost, however, if B returns to A and A calls C,

then the variable loses its contents (unless I add the variable to Macro A).

 

Here are my test macros that support these findings:

Macro A:

<MACRO RUN Use_ID="FALSE" Name="Macro B" ID="-1" Wait="TRUE"/>
<MACRO RUN Use_ID="FALSE" Name="Macro C" ID="-1" Wait="TRUE"/>

Macro B:

<VARIABLE SET STRING Option="\x00" Destination="%acctnumber[1]%" Value="123456789"/>
<TEXT BOX DISPLAY Title="Account Number - Macro B" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %acctnumber[1]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Macro C:

<TEXT BOX DISPLAY Title="Account Number - Macro C" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %acctnumber[1]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

Additionally, changing macro B to the following will show that the variable kept its contents when C is called by B, but is gone

when the macro returns to A (which then calls C again):

<VARIABLE SET STRING Option="\x00" Destination="%acctnumber[1]%" Value="123456789"/>
<TEXT BOX DISPLAY Title="Account Number - Macro B" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %acctnumber[1]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO RUN Use_ID="FALSE" Name="Macro C" ID="-1" Wait="TRUE"/>

 

Keep in mind, the variable in question, %acctnumber%, was added to Macros B and C, but not to A. Adding the variable to

A fixes the problem.

 

What's more, after Saving All Variables at the end of Macro B (where Macro B returns to Macro A without calling C), and adding a

Restore All variables at the beginning of Macro C, I get the same results as though there were no saved Variable.

 

For some reason, when B returns to A - and A does not contain the variable %acctnumber% - the variable itself ceases to exist,

even in the Saved variables file, so that when Macro C runs, the variable is null. If I run Macro B by itself, and then run Macro C

by itself, the variable is restored as intended.

 

To summarize: Macro A calls Macro B. Macro B establishes the value of a variable then saves all variables before returning to

Macro A. Macro A then calls Macro C which Restores all Variables. The named variable (established in B) is null, despite having

been saved in B and restored in C - most likely due to Macro A lacking the variable in it's own settings.

 

Based on this, I think Save and Restore variables commands are still important and necessary, but potentially bugged. Cory,

Terry, et al. (if you are so inclined), can you please duplicate my results and if you don't think it's a bug, please let me

know... if you do think it is, please also let me know so I can submit a bug report.

 

Thanks everybody... again :) !!!

Link to comment
Share on other sites

"Who's on first?" -Abbott and Costello

 

It's too late in the day to digest that pretzel logic but I'll take a crack.

 

OK first off you do realize you don't need to make all variables arrays right? IE you can use %acctnumber% instead of %acctnumber[1]%.

 

as discussed earlier, it shouldn't be necessary
Ah, but yes it is. This is your problem. If you don't have the var defined in macro A there is no bridge between B and C. You see all macros have their own variable sandbox that expires when they have run their course. But if we call one macro from another we can allow the called macro to play with the variables in the parent macro's sandbox so we can essentially pass values between and in some cases save defining vars. This is why the Global parameter. Without it they do all have their own sandbox.

 

So I do not think it's a bug but rather a usage error and one does not need variable save/restore to accomplish your goals. In this case I would define %acctnumber% as Global in A and not define it at all in B or C. So I think you have the right idea that it need not be defined in all macros but you have it the wrong way around.

 

Here's how I worked it out in my mind. In the var definition read what it says next to the checkbox. It says "Make this variable available to macros called by this macro". Now this is a start but it's a bit misleading. I'm sure they were trying to give an easy short description so I'm not complaining. In your case this explanation works but here's something it doesn't explain. Consider macro A calls macro B and macro A has %number% defined as a global and macro B has %number% defined as a local. Now let's say I set %number% to 1 in A and 2 in B and went back to A. The description might imply that %number% is now 2 but it's actually 1. This is why the term local and global are more accurate. Here's my paradigm. Every macro has access to two sandboxes, local and global. If two or more macros are running at once because they were called by another they all share the global sandbox and all have their own private local sandbox. EG when one macro calls another and we have two running there are three sandboxes, two local and one global. As soon as any macro runs out all of it's variables cease to exist, local or global. Furthermore all macros will first look to their local sandbox first before the global sandbox. So the description next to the check-box makes sense from the perspective of the parent macro because it's putting it out in the common global sandbox so everyone can have at it. I think where people get confused is that they think they need to define the var in the called macro which was probably the designers original intent.

 

The picture in my head is probably a lot more clear than what these words painted. I have to run now but if this is unclear maybe we could set up a phone call and I could explain it better or with a white board. I really hope ISS can get around to adding a web page with some graphics to explain things like this. Maybe I should do it myself.

Link to comment
Share on other sites

Thanks for the reply, Cory... you're one of the most knowledgeable and helpful people on here, so I appreciate the time you give those of

us having difficulty with certain concepts.

OK first off you do realize you don't need to make all variables arrays right? IE you can use %acctnumber% instead of %acctnumber[1]%.
Yes, I realize that, and originally that's all I had, but later realized I would like an array - I deal with multiple account numbers, even when

dealing with just one account, so it's good to keep track of primary and secondary account numbers, and an array is a great way to

accomplish that.

 

Ah, but yes it is. This is your problem. If you don't have the var defined in macro A there is no bridge between B and C. You see all macros have their own variable sandbox that expires when they have run their course. But if we call one macro from another we can allow the called macro to play with the variables in the parent macro's sandbox so we can essentially pass values between and in some cases save defining vars. This is why the Global parameter. Without it they do all have their own sandbox.
Ok, so I need A to have the variable "available" in order to carry the contents from B to C... it's not immediately intuitive, but it does make

sense once you understand that is how it works.

 

In this case I would define %acctnumber% as Global in A and not define it at all in B or C. So I think you have the right idea that it need not be defined in all macros but you have it the wrong way around.
Macro A has no 'personal' use for this variable (which is why I didn't originally define the var within it), it just happens to be the 'parent'

macro tying Macros B and C together. Macro B's sole function is to grab the account number from the database for use in other macros

(Macro A is hardly the only macro using Macro B to gather the account number). Macro C actually needs the account number for use

in accessing account information in another application. Another option that might sound logical would be to have Macro C call Macro B right

at the beginning of its run, but due to other processes and commands within Macro A between when it calls B and when it calls C, the most

streamlined approach is to gather the account number (AKA run Macro B ) at the beginning of Macro A and then hold onto that information

until Macro C is called towards the end of Macro A.

 

Unless what you're saying is that by defining the %acctnumber% variable in Macro A, I could still use it in B and C without expressly

defining it in those macros? I'll have to test that. But that still doesn't address my "bug concern" (next: )

 

So I do not think it's a bug but rather a usage error
The "Bug" I think I see is that even when I "Save All Variables" in B and then "Restore All Variables" in C, any variable not expressly

defined in Macro A gets erased. I don't have a problem adding the variable to Macro A, it's not a big deal, very simple process... but I am

not understanding why the Restore command in C is not restoring the variable to its defined value as saved in Macro B regardless of

whether or not the variable exists in Macro A. Global or Local or called by other macro or not... isn't a saved value a saved value?

Shouldn't it be restored when the Restore command is used? (and just in case Global/Local does make a difference with regards to

Save/Restore - which I believe it does - ALL of my variables are Global... I haven't had occasion to even experiment with Local variables.)

 

That is the possible bug I was wondering about. If it's not a bug, then it's not a bug and there's just a very non-intuitive, possibly

incoherent, explanation as to why it isn't a bug.

Link to comment
Share on other sites

Thanks for the reply, Cory... you're one of the most knowledgeable and helpful people on here, so I appreciate the time you give those of

us having difficulty with certain concepts.

Yes, I realize that, and originally that's all I had, but later realized I would like an array - I deal with multiple account numbers, even when

dealing with just one account, so it's good to keep track of primary and secondary account numbers, and an array is a great way to

accomplish that.

 

Ok, so I need A to have the variable "available" in order to carry the contents from B to C... it's not immediately intuitive, but it does make

sense once you understand that is how it works.

 

Macro A has no 'personal' use for this variable (which is why I didn't originally define the var within it), it just happens to be the 'parent'

macro tying Macros B and C together. Macro B's sole function is to grab the account number from the database for use in other macros

(Macro A is hardly the only macro using Macro B to gather the account number). Macro C actually needs the account number for use

in accessing account information in another application. Another option that might sound logical would be to have Macro C call Macro B right

at the beginning of its run, but due to other processes and commands within Macro A between when it calls B and when it calls C, the most

streamlined approach is to gather the account number (AKA run Macro B ) at the beginning of Macro A and then hold onto that information

until Macro C is called towards the end of Macro A.

 

Unless what you're saying is that by defining the %acctnumber% variable in Macro A, I could still use it in B and C without expressly

defining it in those macros? I'll have to test that. But that still doesn't address my "bug concern" (next: )

 

The "Bug" I think I see is that even when I "Save All Variables" in B and then "Restore All Variables" in C, any variable not expressly

defined in Macro A gets erased. I don't have a problem adding the variable to Macro A, it's not a big deal, very simple process... but I am

not understanding why the Restore command in C is not restoring the variable to its defined value as saved in Macro B regardless of

whether or not the variable exists in Macro A. Global or Local or called by other macro or not... isn't a saved value a saved value?

Shouldn't it be restored when the Restore command is used? (and just in case Global/Local does make a difference with regards to

Save/Restore - which I believe it does - ALL of my variables are Global... I haven't had occasion to even experiment with Local variables.)

 

That is the possible bug I was wondering about. If it's not a bug, then it's not a bug and there's just a very non-intuitive, possibly

incoherent, explanation as to why it isn't a bug.

 

I'd be happy to try to reproduce the scenario here but I'm not clear I'd do so faithfully. Could you perhaps distill each of the 3 macros A, B and C to bare essentials, with simple variable names (X, Y, etc), showing the command text and actual code?

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Unless what you're saying is that by defining the %acctnumber% variable in Macro A, I could still use it in B and C without expressly defining it in those macros?
If you read my post carefully I gave you that exact example and told you this is the proper solution. Define a global var in A and do not define it in B or C. It will complain at save about syntax so for that reason you might want to define them in B & C but they are unnecessary. I know you want to define them only where they are needed but you do need it in A to pass from B to C.

 

As far as the save/restore bug I'll be willing to bet you a six pack that ISS will tell you this is not a bug. I don't know exactly how the save/restore mechanism works but I'd be willing to bet this behavior is caused b the same mechanism we discussed about global variables.

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