stevecasper Posted December 28, 2008 Report Share Posted December 28, 2008 Hello all, I just started playing around with running two macros at the same time and I've run into a wall. Maybe what I'm trying to do is not possible right now, but if it is, I'd love to know how to do it. These are just a couple of test macros, so they don't currently have any practical value for me, but here's what I'm trying to accomplish: Run macro with extended delay (25 minutes). Run second macro while first is still processing. Second macro will calculate how long the delay has been running. Unfortunately, the second macro isn't accessing the variable data from the first macro, despite having Save All Variables in the first macro and Restore All Variables in the second one. Here is the actual code, so if somebody wants to let me know what I've done wrong, or what I could do better, that would be great! (Also, I think I could probably eliminate the conversion of D/T variables to Dec variables and back, if I could get the 2nd macro to access the variable info from the first one... the conversions were actually a product of me trying to figure out what I was doing wrong.) Macro 1: <DATE/TIME Flags="\xB0" Date="12/28/2008 9:45:11 AM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%DTyt%" IsDateVar="TRUE"/> <CONVERT DATE/TIME TO DECIMAL Source="%DTyt%" Dest="%decyt%"/> <VARIABLE SAVE Option="\x00"/> <TEXT BOX DISPLAY Title="Delay Start" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs16 The delay started at:\r\n\\par %\\f1 DTyt\\f0 %\r\n\\par }\r\n" Left="820" Top="295" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x02" Delay="0"/> <DELAY Flags="\x01" Time="1500"/> <TEXT BOX CLOSE Header="Delay Start"/> Macro 2 <VARIABLE RESTORE Option="\x00"/> <DATE/TIME Flags="\xB0" Date="12/28/2008 9:46:35 AM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%DTytc%" IsDateVar="TRUE"/> <CONVERT DATE/TIME TO DECIMAL Source="%DTytc%" Dest="%Decytc%"/> <VARIABLE MODIFY DECIMAL Option="\x01" Destination="%D[1]%" Value1="%Decytc%" Value2="%decyt%"/> <CONVERT DECIMAL TO DATE/TIME Source="%D[1]%" Dest="%TimeRun%"/> <TEXT BOX DISPLAY Title="How long?" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %TimeRun%\r\n\\par %Decyt%\r\n\\par %DTytc%\\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"/> Thanks! Quote Link to comment Share on other sites More sharing options...
terrypin Posted December 28, 2008 Report Share Posted December 28, 2008 I'm pretty sure I've reproduced that problem. My code has some trivial changes so that I could more easily identify what I was doing: First macro: Date/Time: Set %Start% to the current date/time Convert Date/Time to Decimal: %Start% => %StartDec% Variable Save: Save All Variables Text Box Display: Delay Start Delay: 1500 seconds Text Box Close: Delay Start Macro Return <DATE/TIME Flags="\xB0" Date="30/12/1899" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%Start%" IsDateVar="TRUE"/> <CONVERT DATE/TIME TO DECIMAL Source="%Start%" Dest="%StartDec%"/> <VARIABLE SAVE Option="\x00"/> <TEXT BOX DISPLAY Title="Delay Start" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs16 The delay started at:\r\n\\par %\\f1 Start\\f0 %\r\n\\par }\r\n" Left="820" Top="295" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x02" Delay="0"/> <DELAY Flags="\x01" Time="1500"/> <TEXT BOX CLOSE Header="Delay Start"/> <MACRO RETURN/> Second macro: Variable Restore: Restore All Variables Date/Time: Set %Later% to the current date/time Convert Date/Time to Decimal: %Later% => %LaterDec% Variable Modify Decimal: %ResultDec% = %LaterDec% - %StartDec% Convert Decimal to Date/Time: %ResultDec% => %TimeRun% Text Box Display: How long? Macro Return <VARIABLE RESTORE Option="\x00"/> <DATE/TIME Flags="\xB0" Date="30/12/1899" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%Later%" IsDateVar="TRUE"/> <CONVERT DATE/TIME TO DECIMAL Source="%Later%" Dest="%LaterDec%"/> <VARIABLE MODIFY DECIMAL Option="\x01" Destination="%ResultDec%" Value1="%LaterDec%" Value2="%StartDec%"/> <CONVERT DECIMAL TO DATE/TIME Source="%ResultDec%" Dest="%TimeRun%"/> <TEXT BOX DISPLAY Title="How long?" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Macro 1 started at\\b Start\\b0 = %Start% (= %StartDec%)\r\n\\par Macro 2 started at \\b Later\\b0 = %Later% (= %LaterDec%)\r\n\\par \r\n\\par So \\b TimeRun\\b0 = %TimeRun%\\f1 \r\n\\par }\r\n" Left="727" Top="609" Width="546" Height="219" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO RETURN/> The result I see is: -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
terrypin Posted December 28, 2008 Report Share Posted December 28, 2008 The result looked a bit better when I got rid of the decimal conversion in macro 2 and instead used this: Variable Restore: Restore All Variables Date/Time: Set %Later% to the current date/time Variable Modify Date/Time: %TimeRun% = %Start% - %Later% Text Box Display: How long? Macro Return <VARIABLE RESTORE Option="\x00"/> <DATE/TIME Flags="\xB0" Date="30/12/1899" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%Later%" IsDateVar="TRUE"/> <VARIABLE MODIFY DATE/TIME DateVar="%TimeRun%" Option="\x01" LeftVar="%Start%" RightVal="%Later%" UseInteger="TRUE" MathOpt="\x00"/> <TEXT BOX DISPLAY Title="How long?" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Macro 1 started at\\b Start\\b0 = %Start% (= %StartDec%)\r\n\\par Macro 2 started at \\b Later\\b0 = %Later% (= %LaterDec%)\r\n\\par \r\n\\par So \\b TimeRun\\b0 = %TimeRun%\\f1 \r\n\\par }\r\n" Left="727" Top="609" Width="546" Height="219" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO RETURN/> Here's the resultant message in How long? Macro 1 started at Start = 28/12/2008 19:29:12 (= 0) Macro 2 started at Later = 28/12/2008 19:30:42 (= 0.0) So TimeRun = 30/12/1899 00:01:30 No idea where ME gets that date from! Can't do more on this right now; please let me know of any conclusions. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
stevecasper Posted December 28, 2008 Author Report Share Posted December 28, 2008 Here's the resultant message in How long? Macro 1 started at Start = 28/12/2008 19:29:12 (= 0) Macro 2 started at Later = 28/12/2008 19:30:42 (= 0.0) So TimeRun = 30/12/1899 00:01:30 No idea where ME gets that date from! Can't do more on this right now; please let me know of any conclusions. -- Terry, East Grinstead, UK Ok, I'm still playing with this, and still not having any luck. I get similar results when I copy your code into my Editor, but when I just build it from scratch following your commands, my results are not even close. Something I noticed about your code is that your ME Pro is assigning 30/12/1899 as today's date (this is actually captured inside your Direct Editor script), which may mean there is a communication error between ME Pro and your computer. This is not duplicated in my ME Pro which is capturing today's date. That might be part of the problem, and certainly explains why that year is popping up in your Text Box Display. Quote Link to comment Share on other sites More sharing options...
stevecasper Posted December 28, 2008 Author Report Share Posted December 28, 2008 Ok, I've gone completely basic. Saved Variables are not being restored. Here are the two most basic macros for example: Macro 1: Variable Set String %TStart% to "Today" Variable Set Integer %NStart% to 2008 Variable Set Decimal %DStart% to 0.535 Date/Time: Set %DTStart% to the current date/time Text Box Display: Variable Save: Save All Variables <VARIABLE SET STRING Option="\x00" Destination="%TStart%" Value="Today"/> <VARIABLE SET INTEGER Option="\x00" Destination="%NStart%" Value="2008"/> <VARIABLE SET DECIMAL Option="\x00" Destination="%DStart%" Value="0.535"/> <DATE/TIME Flags="\xB0" Date="12/28/2008 2:00:06 PM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%DTStart%" IsDateVar="TRUE"/> <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Text = %TStart%\r\n\\par Intg. = %NStart%\r\n\\par Dec = %DStart%\r\n\\par D/T = %DTStart%\\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"/> <VARIABLE SAVE Option="\x00"/> Macro 2: Variable Restore: Restore All Variables Text Box Display: <VARIABLE RESTORE Option="\x00"/> <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Text = %TStart%\r\n\\par Intg. = %NStart%\r\n\\par Dec = %DStart%\r\n\\par D/T = %DTStart%\\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"/> -Edit Well, something is amiss. After I posted this, I ran the macros again and this time the Restore command worked. Further tests and changes to the initial macro also worked. I don't know what the problem is exactly, but I have some doubts about whether or not th Restore command is fully operational 100% of the time. Quote Link to comment Share on other sites More sharing options...
stevecasper Posted December 28, 2008 Author Report Share Posted December 28, 2008 Ok, I think I'm going to submit a bug report soon, because my results are VERY inconsistent. Latest test: Macro 1: Date/Time: Set %Start% to the current date/time Variable Save: Save All Variables <DATE/TIME Flags="\xB0" Date="12/28/2008 2:15:13 PM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%Start%" IsDateVar="TRUE"/> <VARIABLE SAVE Option="\x00"/> Macro 2 was initially (and it worked just fine): Variable Restore: Restore All Variables Text Box Display: Today? <VARIABLE RESTORE Option="\x00"/> <TEXT BOX DISPLAY Title="Today?" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Start%\\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"/> I then added (and it still worked fine): Date/Time: Set %Later% to the current date/time Text Box Display: Today? <DATE/TIME Flags="\xB0" Date="12/28/2008 2:16:07 PM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%Later%" IsDateVar="TRUE"/> <TEXT BOX DISPLAY Title="Today?" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Start%\r\n\\par %Later%\\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"/> And finally I tried the following, at which point the Restore ceased to function at all: Variable Modify Date/Time: %Diff% = %Later% - %Start% Text Box Display: Today? <VARIABLE MODIFY DATE/TIME DateVar="%Diff%" Option="\x01" LeftVar="%Later%" RightVal="%Start%" UseInteger="TRUE" MathOpt="\x00"/> <TEXT BOX DISPLAY Title="Today?" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Start%\r\n\\par %Later%\r\n\\par %Diff%\\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"/> Even when I remove the commands that are apparently breaking the macro, it continues to malfunction. My result in the "Today?" Text box (variable %start%) becomes 0.0 Quote Link to comment Share on other sites More sharing options...
stevecasper Posted December 28, 2008 Author Report Share Posted December 28, 2008 <sigh> I'm about to give up on this one. I think I found the problem. I don't know why it worked originally, but it seems my variable %Start% got re-assigned as a Text variable rather than a Date/Time variable, which caused the Restore command to stop recognizing the originally established value (from macro 1). I manually assigned %Start% to the Date/Time category within macro 2 and now the macro is working consistently. However, I have now duplicated Terry's situation: Variable Modify Date/Time: %Diff% = %Later% - %Start% This line should subtract the Starting time-stamp from the Later time-stamp and give the difference. The resulting time- stamp (%Diff%) displays: 12/30/1899 12:07:37 (the hh:mm:ss changes each time I run Macro 2, so something is working) Converting the D/T to Dec before calculating the difference and then converting back gives the same results. With a little work, I've come up with an inelegant work-around. It's not perfect, but it should be adequate, better with more work. It seems to me the Modify Date/Time command needs some work, though... pretty disappointing if this is how it's supposed to work. Here's my work-around (macro 2): Variable Restore: Restore All Variables Date/Time: Set %Later% to the current date/time Variable Modify Date/Time: Extract hour into %N[1]% Variable Modify Date/Time: Extract minute into %N[2]% Variable Modify Date/Time: Extract second into %N[3]% Variable Modify Date/Time: Extract hour into %N[4]% Variable Modify Date/Time: Extract minute into %N[5]% Variable Modify Date/Time: Extract second into %N[6]% Variable Modify Integer: %N[7]% = %N[1]% - %N[4]% Variable Modify Integer: %N[8]% = %N[2]% - %N[5]% Variable Modify Integer: %N[9]% = %N[3]% - %N[6]% Text Box Display: Time Difference <VARIABLE RESTORE Option="\x00"/> <DATE/TIME Flags="\xB0" Date="12/28/2008 2:16:07 PM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%Later%" IsDateVar="TRUE"/> <VARIABLE MODIFY DATE/TIME DateVar="%Later%" Option="\x05" LeftVar="%N[1]%" UseInteger="FALSE" MathOpt="\x00"/> <VARIABLE MODIFY DATE/TIME DateVar="%Later%" Option="\x06" LeftVar="%N[2]%" UseInteger="FALSE" MathOpt="\x00"/> <VARIABLE MODIFY DATE/TIME DateVar="%Later%" Option="\x07" LeftVar="%N[3]%" UseInteger="FALSE" MathOpt="\x00"/> <VARIABLE MODIFY DATE/TIME DateVar="%Start%" Option="\x05" LeftVar="%N[4]%" UseInteger="FALSE" MathOpt="\x00"/> <VARIABLE MODIFY DATE/TIME DateVar="%Start%" Option="\x06" LeftVar="%N[5]%" UseInteger="FALSE" MathOpt="\x00"/> <VARIABLE MODIFY DATE/TIME DateVar="%Start%" Option="\x07" LeftVar="%N[6]%" UseInteger="FALSE" MathOpt="\x00"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%N[7]%" Value1="%N[1]%" Value2="%N[4]%"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%N[8]%" Value1="%N[2]%" Value2="%N[5]%"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%N[9]%" Value1="%N[3]%" Value2="%N[6]%"/> <TEXT BOX DISPLAY Title="Time Difference" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Start%\r\n\\par %Later%\r\n\\par %N[7]%:%N[8]%:%N[9]%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> I haven't figured out yet if this will work while macro 1 is still running... I don't plan on posting about it when I do modify Macro 1 again... but who knows. Quote Link to comment Share on other sites More sharing options...
terrypin Posted December 28, 2008 Report Share Posted December 28, 2008 What we badly need at this point is an analysis by ME Support about what's going on, and what bugs are identified. Meanwhile I'll be steering well clear of these Date/Time commands. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Cory Posted December 30, 2008 Report Share Posted December 30, 2008 I spotted a bug on 11/15 in build 99 where Variable Restore was not working. It's still appearing as open in my list and I don't see any later emails that it was fixed. I know they identified the problem and were working on fixing it. It was assigned tracking number ISS6184 so you might want to mention this in any support correspondence. Quote Link to comment Share on other sites More sharing options...
kevin Posted December 31, 2008 Report Share Posted December 31, 2008 Just prior to the release of Macro Express Pro a change was made to the Save/Restore Variables commands. These now only affect Global variables. Make sure your variables are defined as Global before using these commands. The documentation is being updated to reflect this change. Quote Link to comment Share on other sites More sharing options...
stevecasper Posted December 31, 2008 Author Report Share Posted December 31, 2008 Just prior to the release of Macro Express Pro a change was made to the Save/Restore Variables commands. These now only affect Global variables. Make sure your variables are defined as Global before using these commands. The documentation is being updated to reflect this change. Hmm, The Scope of the macros I described above are all set to Global (I rarely change that when testing unfamiliar commands). The problem, it seems, was simply that a variable (%Start%) was "understood" by Macro 1 to be a Date/Time variable, and kept it's identity as such when Macro 2 was very basic. As soon as Macro 2 became a little more complex, Macro 2 decided to default %Start% back to a Text variable. It was a nuisance, but once understood, easily remedied. Now my concern is that the Modify Date/Time doesn't seem to be working correctly (or if it is, it is very confusing and not immediately intuitive). I will review the help pages in depth, build some different test macros, and if I think necessary, I'll start a new thread or just file a bug report. Quote Link to comment Share on other sites More sharing options...
Cory Posted December 31, 2008 Report Share Posted December 31, 2008 Like you I was very excited about the time variables but IMHO they were not implemented in an intuitive fashion. In the beta there were so many shortfalls (there's a lot of history here that makes it understandable) that I had all but given up on it. Late in the game they made many changes that make it at least useful now but I still think I would have done it different as I believe it's still deficient in many ways. I pray that down the road there will be time to reconsider and hopefully they will listen to my advice! In any case after much exposure and trials and tribs I think I have a pretty good grasp of their function and the theory behind so feel free to ask me directed questions. I might even write my own tutorial on them for everyone's benefit. 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.