Jump to content
Macro Express Forums

Challenge: A macro to log "Run Macro" commands in MEP scripts


Recommended Posts

The challenge:

 

Write a Macro Express script to step through the Macro Explorer, open each macro, search for "Macro Run" commands, and if found, append the names of the called macros to a text file. The log file should also include the name of the macro that includes "Macro Run" commands.

 

Bonus points if you figure out a way to include the last run time of the macro that includes "Macro Run" commands.

 

If you come up with a different method to generate the log file than suggested above, so much the better.

 

Why this macro might be useful:

 

Macro Express does not update the "Last Run Time" for called macros.

 

Let's say we have two MEP scripts "A" and "B." The first script, "A" includes a "Run Macro" command that calls "B."

 

Checking Macro Express Pro Explorer, we can ascertain when "A" was run by glancing at the "Last Run Time" column. Although "A" called "B," the "Last Run Time" gives no clue that "B" was run.

 

To sum up: the purpose of this challenge is to create a workaround to a minor limitation of Macro Express Pro. I'm going to submit a feature request: macros that are called should be handled like macros that are activated when it comes to updating "Last Run Time." Hopefully the good people at Insight Software will be able to change this behaviour. But if they cannot, at least there will be a workaround.)

Link to comment
Share on other sites

I suspect your "Challenges" are really you just getting people to write macros for you. 🙂 

Anyway, Tom Sawyer, I wrote a macro for this ages ago and I was just working with Terry on it. I don't like how many people want to dive into the GUI on something like this, it's just a mess. It's much easier to export the macro information to a file and process the text file. 

Search and report on macro text.mex

  • Haha 1
Link to comment
Share on other sites

Cory, I hadn't thought about the possibility of analyzing Macro Express log files for data about when called macros were run. 

 

But if that data isn't contained in the log files, there may be no way to get answers but to hunt for information in the user interface. And you're right, this approach could get messy. I think it's do-able, but I haven't tried yet!

 

(BTW, for each challenge I have posted on this forum, I already had a working solution. But not this time. In the past, the solutions submitted by others have sometimes compelled me to rethink my original approach, and go back modify my solution. Ideas from rberq, Terry, Joe, and others have been especially thought-provoking. I've learned a lot from these challenges.)

Link to comment
Share on other sites

Cory, you're the winner! I never knew that I could exported a file that captures macro names and scripts only.

 

The challenge becomes manipulating text rather than the  Macro Express user interface. Great solution.

 

I submited a feature request.

Link to comment
Share on other sites

So I wrote this macro anyway, to get practice working with ME Pro instead of ME 3.  I had a few hours of frustrating failure with what I knew to be FAULTLESS code (the kind I always write🙄), until I figured out what it means to process or not process embedded variables.  

 

This macro scans a macro selected from the Macro Explorer and reports main macro name and macros called from within the main macro.  It does this by copying the Direct Editor code into a variable, then analyzing that.  It only scans one macro, then quits, but before it quits it advances to the next in the Explorer list.  Therefore it should work well with a “driver” macro that simply calls the scanner 10 times in succession, or 100 times, or 1,000 ….  See additional documentation in comment statements near the beginning of the macro text.  

 

I STRONGLY recommend running this against a copy of your live macro file, not against the “real” one.  In theory, it makes no changes to any macro.  But I hate to turn loose a process intended to interact, at very high speed, with hundreds of valuable macros – if something goes awry, who knows what damage might be caused.  I’m going to look into Cory’s “export” technique; probably faster than running in the Explorer and Editor, but I assume parsing out the commands would be much the same.  
 


Lock Player: Wait for running macros to stop
Log Errors to "C:\Temp\MacroExpressProLogFiles\MacroExpressPro_Macro_Log_File.txt"
Log Messages to "C:\Temp\MacroExpressProLogFiles\MacroExpressPro_Macro_Log_File.txt"
  "Macro executed: TempRunCommandSearch"
Log Errors to Default Macro Log
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Keystroke Speed: 10 milliseconds
Mouse Speed: 30 milliseconds
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//  
// MACRO TO FIND "MACRO RUN" COMMANDS WITHIN A "MAIN" MACRO
//  
// This macro was written and tested with Macro Express Pro (ME version 4).
// This macro scans macro text to find MACRO RUN commands.
// An output report (text) file is written containing the name of the main (scanned)
// macro, followed by the names of all called macros.
// If the main macro does no calls, then its name is not written to the report.
// If a macro is called multiple times by the main macro, its name is listed only once.
// Processing should begin with Macro Explorer open, and the macro to be scanned
// should be highlighted (selected).  
// This macro:
// 1) Opens the main macro in the Macro Editor and extracts the name (nickname).
// 2) Switches to the Direct editor.
// 3) Copies the Direct editor script to the clipboard and then to a text variable.
// 4) Closes Macro Editor and arrows down to the next macro line within Explorer.
// 5) Parses the copied script to extract names from MACRO RUN commands, writes report.  
// This macro is best run by a second "driver" macro that activates it multiple times.
// Because it processes the macro selected in Explorer, then selects the subsequent
// macro, a large number of scripts may be scanned by one start of the "driver" macro.
// For safety, this macro should be run against a temporary test copy of the macro file,
// not against a live macro file.   
//  
// For testing, delete the output text file if it exists
Delete File/Files: "c:\temp\test_called_macros.txt"
// Type ENTER in Macro Explorer to open highlighted macro in Editor
Text Type (Simulate Keystrokes): <ENTER>
// Wait for Editor to open
Repeat Until %dummy% Does not Equal "%dummy%"
  If Window "Macro Express Pro - Script Editor" is focused
    Repeat Exit
  Else
    Delay: 100 milliseconds
  End If
End Repeat
// Alt-n to go to macro nickname field
Text Type (Simulate Keystrokes): <ALTD>n<ALTU>
// Highlight macro nickname and copy to clipboard, then to variable mainmac, then END to release the highlighting
Text Type (Simulate Keystrokes): <SHIFTD><END><SHIFTU>
Macro Run: 0_Generic_Copy_To_Clipboard
Variable Set String %mainmac% from the clipboard contents
Text Type (Simulate Keystrokes): <END>
Text Box Display: Diagnostics
// Alt-i to get to script tab, then Alt-v (View) and letter i for Direct Editor
Text Type (Simulate Keystrokes): <ALTD>i<ALTU>
Text Type (Simulate Keystrokes): <ALTD>v<ALTU>i
Delay: 1000 milliseconds
// At this point the main macro should be visible in the Direct Editor
// Ctrl-a to highlight the entire macro script, copy to clipboard then to %maintext% variable, type END to clear the highlighting
Text Type (Simulate Keystrokes): <CTRLD>a<CTRLU>
Delay: 1000 milliseconds
Macro Run: 0_Generic_Copy_To_Clipboard
Variable Set String %maintext% from the clipboard contents
Text Type (Simulate Keystrokes): <END>
Text Box Display: Diagnostics
// Close Macro Editor.  FROM HERE ON WE WILL WORK WITH VARIABLES, NOT IN THE MACRO EDITOR.
Text Type (Simulate Keystrokes): <ALTD>s<ALTU>c
// Wait until Editor is closed and Macro Explorer is focused
Repeat Until %dummy% Does not Equal "%dummy%"
  If Window "Macro Express Pro - Explorer" is focused
    Repeat Exit
  Else
    Delay: 100 milliseconds
  End If
End Repeat
Text Box Display: Diagnostics
// In Macro Explorer, arrow down to the next macro so we will be ready to process it
Text Type (Simulate Keystrokes): <ARROW DOWN>
Delay: 1000 milliseconds
//  
//  
// Clear working variables:
%called_list% for all called macros found within this main macro.
%display% for lines to be written to the output text file.
Variable Set String %called_list% to ""
Variable Set String %display% to ""
// Clean up the macro script by stripping CR/LF and removing % symbols
Variable Modify String %maintext%: Strip CR/LF
Variable Modify String: Replace "%" in %maintext% with ""
// If macro text contains a Macro Run command, send the main macro name to the output file
// If no Macro Run command within this macro, exit from this macro.
If Variable %maintext% Contains "<MACRO RUN Use_ID=""
  Variable Set String %display% to "   " // blank line to separate report for each scanned macro
  Variable Modify String: Append %display% to text file, "c:\temp\test_called_macros.txt"
  Variable Set String %display% to "Main macro: "
  Variable Modify String %display%: Append Text String Variable (%mainmac%)
  Variable Modify String: Append %display% to text file, "c:\temp\test_called_macros.txt"
Else
  Macro Return
End If
// Entire macro script is in variable %maintext%.  Extract and list each unique macro name found within a MACRO RUN command.  
Repeat Until %maintext% Does not Contain "<MACRO RUN Use_ID=""
//  
  Variable Set Integer %offset% to the position of "<MACRO RUN Use_ID="" in %maintext% // find MACRO RUN command within macro script
  If Variable %offset% Does not Equal "0"
    Variable Modify Integer: %offset% = %offset% + 18
    Text Box Display: Diagnostics
    Macro Return
    Variable Modify String %maintext%: Delete a substring starting at 1 and %offset% characters long // delete all macro script up through MACRO RUN ... text
    Text Box Display: Diagnostics deleted up through MACRO RUN
  Else
    Text Box Display: Error
    Macro Return
  End If
  //  
  Variable Set Integer %offset% to the position of "name="" in %maintext% // find "name= within remaining macro script
  If Variable %offset% Does not Equal "0"
    Variable Modify Integer: %offset% = %offset% + 5
    Variable Modify String %maintext%: Delete a substring starting at 1 and %offset% characters long // delete all macro script up to and including "name="
    Text Box Display: Diagnostics deleted up through name=
  Else
    Text Box Display: Error
    Macro Return
  End If
  //  
  Variable Set Integer %offset% to the position of """ in %maintext% // find quotation mark terminating the name of the called macro within the MACRO RUN command
  If Variable %offset% Does not Equal "0"
    Variable Modify Integer %offset%: Decrement
    Variable Modify String: Copy a substring in %maintext%, starting at 1 and %offset% characters long to %called_name% // extract the called macro name from the Macro Run command
    Text Box Display: Diagnostics
  Else
    Text Box Display: Error
    Macro Return
  End If
  // If name of called macro is not already in "called_list", put it there and send name to output text file
  // If the called macro name has already been found (is in called_list), bypass it so output file won't contain duplicates
  // Add "xxxxxxxxxx" to the name inserted in "called_list", so subsets of the name won't be confused with the full name.
  Variable Modify String %extended_called_name%: Copy Whole Text (%called_name%)
  Variable Modify String %extended_called_name%: Append Text (xxxxxxxxxx)
  Text Box Display: Diagnostics before filling called_list
  If Variable %called_list% Does not Contain "%extended_called_name%"
  Text Box Display: Diagnostics is called name in list?
    Variable Modify String %called_list%: Append Text String Variable (%extended_called_name%)
    Text Box Display: Diagnostics after filling called_list
    Variable Set String %display% to "Called macro: "
    Variable Modify String %display%: Append Text String Variable (%called_name%)
    Variable Modify String: Append %display% to text file, "c:\temp\test_called_macros.txt"
  End If
  //  
End Repeat
//  
Text Box Display: Diagnostics
//  
//  
//  
//  
//  
//  
//  
Macro Return
//  
Unlock Player

 


<LOCK PLAYER Wait="TRUE"/>
<LOG ERRORS Filename="C:\\Temp\\MacroExpressProLogFiles\\MacroExpressPro_Macro_Log_File.txt" Hide_Errors="TRUE"/>
<LOG MESSAGES Filename="C:\\Temp\\MacroExpressProLogFiles\\MacroExpressPro_Macro_Log_File.txt" Message="Macro executed: TempRunCommandSearch" Stamp="TRUE"/>
<LOG ERRORS Hide_Errors="FALSE" _ENABLED="FALSE"/>
<COMMENT Value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
<KEYSTROKE SPEED Delay="10"/>
<MOUSE SPEED Delay="30"/>
<COMMENT Value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
<COMMENT Value=" "/>
<COMMENT Value="MACRO TO FIND \"MACRO RUN\" COMMANDS WITHIN A \"MAIN\" MACRO "/>
<COMMENT Value=" "/>
<COMMENT Value="This macro was written and tested with Macro Express Pro (ME version 4). "/>
<COMMENT Value="This macro scans macro text to find MACRO RUN commands."/>
<COMMENT Value="An output report (text) file is written containing the name of the main (scanned)"/>
<COMMENT Value="macro, followed by the names of all called macros."/>
<COMMENT Value="If the main macro does no calls, then its name is not written to the report."/>
<COMMENT Value="If a macro is called multiple times by the main macro, its name is listed only once."/>
<COMMENT Value="Processing should begin with Macro Explorer open, and the macro to be scanned"/>
<COMMENT Value="should be highlighted (selected).  "/>
<COMMENT Value="This macro:"/>
<COMMENT Value="1) Opens the main macro in the Macro Editor and extracts the name (nickname)."/>
<COMMENT Value="2) Switches to the Direct editor."/>
<COMMENT Value="3) Copies the Direct editor script to the clipboard and then to a text variable."/>
<COMMENT Value="4) Closes Macro Editor and arrows down to the next macro line within Explorer."/>
<COMMENT Value="5) Parses the copied script to extract names from MACRO RUN commands, writes report.  "/>
<COMMENT Value="This macro is best run by a second \"driver\" macro that activates it multiple times. "/>
<COMMENT Value="Because it processes the macro selected in Explorer, then selects the subsequent "/>
<COMMENT Value="macro, a large number of scripts may be scanned by one start of the \"driver\" macro. "/>
<COMMENT Value="For safety, this macro should be run against a temporary test copy of the macro file, "/>
<COMMENT Value="not against a live macro file.   "/>
<COMMENT Value=" "/>
<COMMENT Value="For testing, delete the output text file if it exists "/>
<DELETE FILE/FILES Path="c:\\temp\\test_called_macros.txt" Progress="FALSE" Recurse="FALSE" Permanent="TRUE" _ENABLED="FALSE"/>
<COMMENT Value="Type ENTER in Macro Explorer to open highlighted macro in Editor "/>
<TEXT TYPE Action="0" Text="<ENTER>"/>
<COMMENT Value="Wait for Editor to open "/>
<REPEAT UNTIL Variable="%dummy%" Condition="\x01" Value="%dummy%"/>
<IF WINDOW Option="\x00" Title="Macro Express Pro - Script Editor" Partial="TRUE" Wildcards="FALSE"/>
<REPEAT EXIT/>
<ELSE/>
<DELAY Flags="\x12" Time="100"/>
<END IF/>
<END REPEAT/>
<COMMENT Value="Alt-n to go to macro nickname field "/>
<TEXT TYPE Action="0" Text="<ALTD>n<ALTU>"/>
<COMMENT Value="Highlight macro nickname and copy to clipboard, then to variable mainmac, then END to release the highlighting "/>
<TEXT TYPE Action="0" Text="<SHIFTD><END><SHIFTU>"/>
<MACRO RUN Use_ID="FALSE" Name="0_Generic_Copy_To_Clipboard" ID="-1" Wait="TRUE"/>
<VARIABLE SET STRING Option="\x02" Destination="%mainmac%" NoEmbeddedVars="FALSE"/>
<TEXT TYPE Action="0" Text="<END>"/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 mainmac = %mainmac%\\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" _ENABLED="FALSE"/>
<COMMENT Value="Alt-i to get to script tab, then Alt-v (View) and letter i for Direct Editor "/>
<TEXT TYPE Action="0" Text="<ALTD>i<ALTU>"/>
<TEXT TYPE Action="0" Text="<ALTD>v<ALTU>i"/>
<DELAY Flags="\x12" Time="1000" _ENABLED="FALSE"/>
<COMMENT Value="At this point the main macro should be visible in the Direct Editor "/>
<COMMENT Value="Ctrl-a to highlight the entire macro script, copy to clipboard then to %maintext% variable, type END to clear the highlighting"/>
<TEXT TYPE Action="0" Text="<CTRLD>a<CTRLU>"/>
<DELAY Flags="\x12" Time="1000" _ENABLED="FALSE"/>
<MACRO RUN Use_ID="FALSE" Name="0_Generic_Copy_To_Clipboard" ID="-1" Wait="TRUE"/>
<VARIABLE SET STRING Option="\x02" Destination="%maintext%" NoEmbeddedVars="FALSE"/>
<TEXT TYPE Action="0" Text="<END>"/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 maintext = %maintext%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<COMMENT Value="Close Macro Editor.  FROM HERE ON WE WILL WORK WITH VARIABLES, NOT IN THE MACRO EDITOR."/>
<TEXT TYPE Action="0" Text="<ALTD>s<ALTU>c"/>
<COMMENT Value="Wait until Editor is closed and Macro Explorer is focused"/>
<REPEAT UNTIL Variable="%dummy%" Condition="\x01" Value="%dummy%"/>
<IF WINDOW Option="\x00" Title="Macro Express Pro - Explorer" Partial="TRUE" Wildcards="FALSE"/>
<REPEAT EXIT/>
<ELSE/>
<DELAY Flags="\x12" Time="100"/>
<END IF/>
<END REPEAT/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 ME Editor has been closed and Explorer is in focus\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<COMMENT Value="In Macro Explorer, arrow down to the next macro so we will be ready to process it "/>
<TEXT TYPE Action="0" Text="<ARROW DOWN>"/>
<DELAY Flags="\x12" Time="1000" _ENABLED="FALSE"/>
<COMMENT Value=" "/>
<COMMENT Value=" "/>
<COMMENT Value="Clear working variables:\r\n%called_list% for all called macros found within this main macro.\r\n%display% for lines to be written to the output text file."/>
<VARIABLE SET STRING Option="\x00" Destination="%called_list%" NoEmbeddedVars="TRUE"/>
<VARIABLE SET STRING Option="\x00" Destination="%display%" NoEmbeddedVars="TRUE"/>
<COMMENT Value="Clean up the macro script by stripping CR/LF and removing % symbols"/>
<VARIABLE MODIFY STRING Option="\x03" Destination="%maintext%" _ENABLED="FALSE"/>
<VARIABLE MODIFY STRING Option="\x0F" Destination="%maintext%" ToReplace="%" All="TRUE" IgnoreCase="TRUE" NoEmbeddedVars="TRUE"/>
<COMMENT Value="If macro text contains a Macro Run command, send the main macro name to the output file "/>
<COMMENT Value="If no Macro Run command within this macro, exit from this macro."/>
<IF VARIABLE Variable="%maintext%" Condition="\x06" Value="<MACRO RUN Use_ID=\"" IgnoreCase="TRUE"/>
<VARIABLE SET STRING Option="\x00" Destination="%display%" Value="   " NoEmbeddedVars="FALSE" _COMMENT="blank line to separate report for each scanned macro"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%display%" Filename="c:\\temp\\test_called_macros.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%display%" Value="Main macro: " NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%display%" Variable="%mainmac%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%display%" Filename="c:\\temp\\test_called_macros.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/>
<ELSE/>
<MACRO RETURN/>
<END IF/>
<COMMENT Value="Entire macro script is in variable %maintext%.  Extract and list each unique macro name found within a MACRO RUN command.  "/>
<REPEAT UNTIL Variable="%maintext%" Condition="\x07" Value="<MACRO RUN Use_ID=\""/>
<COMMENT Value=" "/>
<VARIABLE SET INTEGER Option="\x0E" Destination="%offset%" Text_Variable="%maintext%" Text="<MACRO RUN Use_ID=\"" Ignore_Case="TRUE" _COMMENT="find MACRO RUN command within macro script"/>
<IF VARIABLE Variable="%offset%" Condition="\x01" Value="0" IgnoreCase="FALSE"/>
<VARIABLE MODIFY INTEGER Option="\x00" Destination="%offset%" Value1="%offset%" Value2="18"/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 offset=%offset%\r\n\\par maintext=%maintext%\\f1 \r\n\\par }\r\n" Left="10" Top="136" Width="1296" Height="544" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="5" _ENABLED="FALSE"/>
<MACRO RETURN _ENABLED="FALSE"/>
<VARIABLE MODIFY STRING Option="\x0A" Destination="%maintext%" Start="1" Count="%offset%" _COMMENT="delete all macro script up through MACRO RUN ... text"/>
<TEXT BOX DISPLAY Title="Diagnostics deleted up through MACRO RUN" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 offset=%offset%\r\n\\par maintext=%maintext%\\f1 \r\n\\par }\r\n" Left="10" Top="136" Width="1296" Height="544" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<ELSE/>
<TEXT BOX DISPLAY Title="Error" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Error parsing \"Macro Run\" command -- macro aborted.\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="457" Height="168" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO RETURN/>
<END IF/>
<COMMENT Value=" "/>
<VARIABLE SET INTEGER Option="\x0E" Destination="%offset%" Text_Variable="%maintext%" Text="name=\"" Ignore_Case="TRUE" _COMMENT="find \"name= within remaining macro script"/>
<IF VARIABLE Variable="%offset%" Condition="\x01" Value="0" IgnoreCase="FALSE"/>
<VARIABLE MODIFY INTEGER Option="\x00" Destination="%offset%" Value1="%offset%" Value2="5"/>
<VARIABLE MODIFY STRING Option="\x0A" Destination="%maintext%" Start="1" Count="%offset%" _COMMENT="delete all macro script up to and including \"name=\""/>
<TEXT BOX DISPLAY Title="Diagnostics deleted up through name=" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 offset=%offset%\r\n\\par maintext=%maintext%\\f1 \r\n\\par }\r\n" Left="10" Top="136" Width="1296" Height="544" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<ELSE/>
<TEXT BOX DISPLAY Title="Error" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Error parsing called-macro name within \"Macro Run\" command -- macro aborted.\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="551" Height="168" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO RETURN/>
<END IF/>
<COMMENT Value=" "/>
<VARIABLE SET INTEGER Option="\x0E" Destination="%offset%" Text_Variable="%maintext%" Text="\"" Ignore_Case="TRUE" _COMMENT="find quotation mark terminating the name of the called macro within the MACRO RUN command"/>
<IF VARIABLE Variable="%offset%" Condition="\x01" Value="0" IgnoreCase="FALSE"/>
<VARIABLE MODIFY INTEGER Option="\x08" Destination="%offset%"/>
<VARIABLE MODIFY STRING Option="\x09" Destination="%called_name%" Variable="%maintext%" Start="1" Count="%offset%" NoEmbeddedVars="TRUE" _COMMENT="extract the called macro name from the Macro Run command"/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 called macro name=%called_name%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="907" Height="184" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<ELSE/>
<TEXT BOX DISPLAY Title="Error" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Error parsing called-macro name within \"Macro Run\" command -- macro aborted.\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="551" Height="168" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO RETURN/>
<END IF/>
<COMMENT Value="If name of called macro is not already in \"called_list\", put it there and send name to output text file"/>
<COMMENT Value="If the called macro name has already been found (is in called_list), bypass it so output file won't contain duplicates"/>
<COMMENT Value="Add \"xxxxxxxxxx\" to the name inserted in \"called_list\", so subsets of the name won't be confused with the full name."/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%extended_called_name%" Variable="%called_name%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%extended_called_name%" Value="xxxxxxxxxx" NoEmbeddedVars="FALSE"/>
<TEXT BOX DISPLAY Title="Diagnostics before filling called_list" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 called_name=%called_name%\r\n\\par extended_called_name=%extended_called_name%\r\n\\par called_list=%called_list%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1245" Height="505" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<IF VARIABLE Variable="%called_list%" Condition="\x07" Value="%extended_called_name%" IgnoreCase="TRUE"/>
<TEXT BOX DISPLAY Title="Diagnostics is called name in list?" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Called name %extended_called_name% \r\n\\par is not in list %called_list%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1245" Height="505" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%called_list%" Variable="%extended_called_name%" NoEmbeddedVars="FALSE"/>
<TEXT BOX DISPLAY Title="Diagnostics after filling called_list" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 called_name=%called_name%\r\n\\par extended_called_name=%extended_called_name%\r\n\\par called_list=%called_list%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1245" Height="505" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%display%" Value="Called macro: " NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%display%" Variable="%called_name%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%display%" Filename="c:\\temp\\test_called_macros.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/>
<END IF/>
<COMMENT Value=" "/>
<END REPEAT/>
<COMMENT Value=" "/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 called_list=%called_list%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1245" Height="505" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<COMMENT Value=" "/>
<COMMENT Value=" "/>
<COMMENT Value=" "/>
<COMMENT Value=" "/>
<COMMENT Value=" "/>
<COMMENT Value=" "/>
<COMMENT Value=" "/>
<MACRO RETURN/>
<COMMENT Value=" "/>
<UNLOCK PLAYER/>

 

Link to comment
Share on other sites

Impressive! What a good way to hone your skills.


There are a couple of Macro Express settings that might reduce the likelihood of things going awry when the script first opens the Scripting Editor:


Make the Direct Editor the default (at least for the purpose of running this script), and always remember the last tab in the Scripting Editor.

 

image.thumb.png.5547e288fb719bf2423643acb448acfc.png

Link to comment
Share on other sites

Well done! Looking forward to trying it in the morning.

 

It will be a neat complement to Cory’s macro, which I use to tackle the reverse task of finding those macros (if any) which run a specified macro as a ‘sub macro’.

Link to comment
Share on other sites

Good idea to make the Direct Editor the default -- that would save a little time for each scan.  Is that an ME 6 option? -- can't find it in ME 4.

 

I wrote a driver for the scan macro and ran it on 33 macros.  Nice round number.  It took slightly over a minute in all.  Screens flash by too fast for me to read much.

    Variable Set Integer %count% to 33
    Repeat Start (Repeat %count% times)
      Macro Run: 9a_Search_Macros_for_Macro_Run_Commands
    End Repeat

 

I also was not aware that Export could put out a text file.  That file could probably be imported into an Excel spreadsheet, add a column to sequentially number each line from one to umpteen, sort to put all "Name:" lines together and all "Macro run" lines together, delete everything else, re-sort on the sequence column, and voila. 

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...
×
×
  • Create New...