Jump to content
Macro Express Forums

Filtering for "Called by Macro" List


Recommended Posts

I have a number of macros that I use as a base for making certain adjustments. One example: a prompt asks for a dollar amount. If

the user inputs "25" for "25.00" my macro will know to add the ".00" automatically, additionally if the amount is "2500", the macro will

convert it to "2,500.00", adding a comma as well as the .00. This basic function is required for a number of macros that I use at work,

and so I just use a "Run Macro" command within all these various other macros.

 

Occasionally I give a macro a name like "Test File Repair" so I know it's just a test macro while I work with it and "beta test" the

functionality before I roll it out to other users. Once that's done, I need to change the macro name, otherwise I may end up several

months later with "Test File Repair 2" etc. and it gets cumbersome and confusing.

 

So when I have half a dozen macros or more calling "Test File Repair," it can sometimes get confusing or I just plain forget which macros

or how many macros are actually calling this one. So occasionally, I change the name, change the Run Macro in as many of the other

macros as I can remember, and then continue testing for a few more days to see if I get any "Macro 'File Repair' could not be found, Macro

will be aborted" errors (indicating a macro whose "Macro Run" was not changed for the new, Final, macro name.

 

Now that I've gotten that long-winded background out of the way, is there any function in ME Pro that I haven't found yet, that will list all

the macros which call a specific macro? Like if I were to right-click on the macro in the Explorer window and select "Macros Calling This

One" menu (I know that particular method won't work).

 

If not, I know a feature I'm going to submit a request for. Anybody know anything about the possibility of this feature's existence?

Link to comment
Share on other sites

I have a number of macros that I use as a base for making certain adjustments. One example: a prompt asks for a dollar amount. If

the user inputs "25" for "25.00" my macro will know to add the ".00" automatically, additionally if the amount is "2500", the macro will

convert it to "2,500.00", adding a comma as well as the .00. This basic function is required for a number of macros that I use at work,

and so I just use a "Run Macro" command within all these various other macros.

 

Occasionally I give a macro a name like "Test File Repair" so I know it's just a test macro while I work with it and "beta test" the

functionality before I roll it out to other users. Once that's done, I need to change the macro name, otherwise I may end up several

months later with "Test File Repair 2" etc. and it gets cumbersome and confusing.

 

So when I have half a dozen macros or more calling "Test File Repair," it can sometimes get confusing or I just plain forget which macros

or how many macros are actually calling this one. So occasionally, I change the name, change the Run Macro in as many of the other

macros as I can remember, and then continue testing for a few more days to see if I get any "Macro 'File Repair' could not be found, Macro

will be aborted" errors (indicating a macro whose "Macro Run" was not changed for the new, Final, macro name.

 

Now that I've gotten that long-winded background out of the way, is there any function in ME Pro that I haven't found yet, that will list all

the macros which call a specific macro? Like if I were to right-click on the macro in the Explorer window and select "Macros Calling This

One" menu (I know that particular method won't work).

 

If not, I know a feature I'm going to submit a request for. Anybody know anything about the possibility of this feature's existence?

 

Steve,

 

Yes, I too have often wanted a search facility like that, along the lines that Joe describes.

 

On occasions I've even resorted to opening my main MEX file (FULL.mex) in Hex Workshop Editor and using its search to find relevant text strings. So one line of attack would be to generalise that.

 

Another sledge-hammer approach might be to periodically run a macro that successively copies all your scripts to a file, allowing you to then search it.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Steve,

 

Yes, I too have often wanted a search facility like that, along the lines that Joe describes.

 

On occasions I've even resorted to opening my main MEX file (FULL.mex) in Hex Workshop Editor and using its search to find relevant text strings. So one line of attack would be to generalise that.

 

Another sledge-hammer approach might be to periodically run a macro that successively copies all your scripts to a file, allowing you to then search it.

 

--

Terry, East Grinstead, UK

Wow... that would be some sledge-hammer.

 

If I were a tad more organized, I'd just keep a running spreadsheet. Unfortunately, when we first got ME here at work, I wasn't the point-person (despite being the only person in the department with any experience with ME), so I only built macros for myself, and occasionally helped the actual point person when he asked for it. So I didn't bother keeping track of anything, since I thought he was (I was mistaken)... Now he's moved on to another job, leaving me on point but without any documentation... in fact, my work with ME is essentially pro bono. I don't get special time to build, filter, document, organize or anything. So, my macros continue to be built according to my personal needs when I can spare a minute or 20, and roll out very sporadically (if ever). They tell me my macros are important to the success of the team, but they don't really show it... Anyway that's a personal gripe.

 

Bottom line: I don't have time to go through every macro and index them. There are some processes that need tweaking so I'm very slowly copying most of my macros from ME3 to MEP by hand, one line at a time, in order to streamline some of my older macros that were built inelegantly (plus this way I can make hefty use of the unlimited variables MEP offers). I'm using this opportunity to pay more attention to which macros are being called by which other macros... but it sure is tedious.

Link to comment
Share on other sites

I had exactly the same problem and actually wrote a macro to do this. Too bad I can't find it now. In any case it's real easy to do manually, we even had a discussion about it back in the ME3 forum a while ago. All you need to do is File > Export > Macro Information then search that file. Make sure to include the script obviously. I wrote a macro once to do exactly that and report either all the Macro Runs or apply a user defined filter. It was really simple and worked super slick! If anyone really wants it I can write it again, it was only something like 20 lines.

Link to comment
Share on other sites

Wow... that would be some sledge-hammer.

 

Not really. As Cory said, the file creation macro is pretty simple. My hasty attempt below is probably a bit crude but it works OK here and produces a 12,000 line file from the 562 macros in my FULL.mex file in under a second.

 

// This will export all scripts to an existing text file called CurrentMacroScripts, replacing its current contents.

Window Activate: Macro Express Pro - Explorer

Keystroke Speed: 10 milliseconds

Text Type (Simulate Keystrokes): <ALT>feo // File > Export > Export Macros...

Wait for Text Playback

Text Type (Simulate Keystrokes): <SPACE><TAB><TAB><SPACE><TAB><SPACE><ENTER> // Configure the export appropriately

Wait for Text Playback

Delay: 1 seconds

Text Type (Simulate Keystrokes): C:\Docs\SUNDRY\Macro Express\CurrentMacroScripts.txt

 

Wait for Text Playback

Text Type (Simulate Keystrokes): y

 

Wait for Text Playback

Macro Return

 

 

(BTW, I've left that paste unedited apart from the formating. Why do I often get apparently blank lines in my script, usually (but not always) after a Text Type command? Such as between commands #9 and #10 above?)

 

 

<COMMENT Value="This will export all scripts to an existing text file called CurrentMacroScripts, replacing its current contents."/>
<WINDOW ACTIVATE Title="Macro Express Pro - Explorer" Exact_Match="FALSE" Wildcards="FALSE"/>
<KEYSTROKE SPEED Delay="10"/>
<TEXT TYPE Action="0" Text="<ALT>feo" _COMMENT="File > Export > Export Macros..."/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT TYPE Action="0" Text="<SPACE><TAB><TAB><SPACE><TAB><SPACE><ENTER>" _COMMENT="Configure the export appropriately"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<DELAY Flags="\x01" Time="1"/>
<TEXT TYPE Action="0" Text="C:\\Docs\\SUNDRY\\Macro Express\\CurrentMacroScripts.txt\r\n"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT TYPE Action="0" Text="y\r\n"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<MACRO RETURN/>

 

Hopefully you or Cory can now write the complementary search macro! ;)

 

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Actually my macro didn't export the file but rather it processed the file line by line and created a report all in script, IE no UI, notepad or any of that. Personally I don't like mucking about in a text editor's UI when I can more easily use variable manipulation commands. Much faster, more reliable, and doesn't bother the user.

Link to comment
Share on other sites

Actually my macro didn't export the file but rather it processed the file line by line and created a report all in script, IE no UI, notepad or any of that. Personally I don't like mucking about in a text editor's UI when I can more easily use variable manipulation commands. Much faster, more reliable, and doesn't bother the user.

 

Cory,

 

Not sure I'm following you there?

 

The above just exports all scripts, using the same Export facility you mentioned. No text editor involved.

 

I vaguely assumed that the search macro would just prompt for a 'target' macro and then simply ASCII process/search the file, displaying the results as a list of macros in a Text Display, or a file if preferred. Again, no text editor. Both macros would then be combined.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Sorry Terry, I didn't really read your macro. I just saw it starting down the GUI path and assumed.

 

My macro worked on any type of command really. This way one could look for all the Macro Run, Set Variable, or whatever. And by the same token it cold look for a specific Macro Run. Just any text you like. Then it would list which macros it was in and copy it to your clipboard if you preferred. I never bothered with the export part becasue that was jsut as east to do manually.

Link to comment
Share on other sites

Sorry Terry, I didn't really read your macro. I just saw it starting down the GUI path and assumed.

 

My macro worked on any type of command really. This way one could look for all the Macro Run, Set Variable, or whatever. And by the same token it cold look for a specific Macro Run. Just any text you like. Then it would list which macros it was in and copy it to your clipboard if you preferred. I never bothered with the export part becasue that was jsut as east to do manually.

 

OK Cory, understood.

 

I wish you could put your hands on your macro! I've been trying for an hour or so but have given up for now. I was placing command script lines into a text variable where I then intended to test it with

If Variable %Command% Contains "<MACRO RUN"

But that's getting screwed up sometimes when the command script line contains strings like '%T[1]%' etc. They get converted to their current values, instead of just being left as plain text. Is there some way to avoid that sort of thing?

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Well this is the problem with percent signs. Many times we deal with text that we don't want to evaluate for potential variables but MEP does it anyway. It's very frustrating. Personally I think they're choice of the common percent sign was a mistake. Should have used the pipe symbol or something less common.

 

I'll look around for that macro or write a new one.

Link to comment
Share on other sites

I don't know Cory, the percent sign is pretty common for script style programs as well as the dollar sign. The pipe and other keyboard characters would have their own baggage as well.

 

Would something like this be possible to build a string?

 

Variable Set String %T[1]% to "%"
Variable Modify String %T[1]%: Append Text (T[1]%)

What you end up with when MX Pro substitutes the variable %T[1]% is the string "%T[1]%".

Link to comment
Share on other sites

Here's my macro to achieve the result we've discussed. It does work here although it's still pretty crude. In particular note my inclusion of Delays and Wait for Text Playback, as I'm still unsure whether the Waits work on their own.

 

I've been forced to split it into two parts for a reason I'll explain later.

 

 

// This first section exports all scripts in the current MEX file to an existing text file called CurrentMacroScripts, replacing its current contents.

Window Activate: Macro Express Pro - Explorer

Keystroke Speed: 10 milliseconds

Text Type (Simulate Keystrokes): <ALT>feo // File > Export > Export Macros...

Wait for Text Playback

Delay: 100 milliseconds, without ability to halt

Text Type (Simulate Keystrokes): <SPACE><TAB><TAB><SPACE><TAB><SPACE><ENTER> // Configure the export appropriately

Wait for Text Playback

Delay: 1 seconds

Text Type (Simulate Keystrokes): C:\Docs\SUNDRY\Macro Express\CurrentMacroScripts.txt

 

Wait for Text Playback

Text Type (Simulate Keystrokes): y

 

Wait for Text Playback

Wait for File to Exist: C:\Docs\SUNDRY\Macro Express\CurrentMacroScripts.txt

Text Box Display: File created

Delay: 100 milliseconds

Macro Return

 

<COMMENT Value="This first section exports all scripts in the current MEX file to an existing text file called CurrentMacroScripts, replacing its current contents."/>
<WINDOW ACTIVATE Title="Macro Express Pro - Explorer" Exact_Match="FALSE" Wildcards="FALSE"/>
<KEYSTROKE SPEED Delay="10"/>
<TEXT TYPE Action="0" Text="<ALT>feo" _COMMENT="File > Export > Export Macros..."/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<DELAY Flags="\x03" Time="100"/>
<TEXT TYPE Action="0" Text="<SPACE><TAB><TAB><SPACE><TAB><SPACE><ENTER>" _COMMENT="Configure the export appropriately"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<DELAY Flags="\x01" Time="1" _ENABLED="FALSE"/>
<TEXT TYPE Action="0" Text="C:\\Docs\\SUNDRY\\Macro Express\\CurrentMacroScripts.txt\r\n"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT TYPE Action="0" Text="y\r\n"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<WAIT FOR FILE TO EXIST Filename="C:\\Docs\\SUNDRY\\Macro Express\\CurrentMacroScripts.txt" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT BOX DISPLAY Title="File created" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 The full data has been exported to the file CurrentMacroScripts.\\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"/>
<DELAY Flags="\x02" Time="100"/>
<MACRO RETURN/>

 

 

// This part gets the macro name entered as a target. It assumes you have the name selected in ME Pro Explorer.

Keystroke Speed: 50 milliseconds

Mouse Right Click: 50 milliseconds

Delay: 100 milliseconds

Text Type (Simulate Keystrokes): p

Wait for Text Playback

Text Type (Simulate Keystrokes): <TAB>

Wait for Text Playback

Clipboard Copy

Variable Set String %Target% from the clipboard contents

// This part searches that file for all commands containing at least one Macro Run for the target macro xyz.

Variable Set to ASCII Char 13 to %CR% // Set CR

Variable Set to ASCII Char 10 to %LF% // Set LF

Variable Set String %CRLF% to "%CR%%LF%"

Variable Set Integer %N[1]% to 1

Text File Begin Process: C:\Docs\SUNDRY\Macro Express\CurrentMacroScripts.txt

If Variable %Text% Contains "Name: " // Test for current macro name

Variable Set String %Macroname% to "%Text%"

Variable Modify String %Macroname%: Delete a substring starting at 1 and 6 characters long

Goto:End

End If

If Variable %Text% Contains "<MACRO RUN Use_ID="FALSE" Name="%Target%" // Test if this command is a MACRO RUN of target macro

And

If Variable %Macroname% Does not Equal "%OldName%" // Test if this command is a MACRO RUN of target macro

// Do whatever is necessary for a hit

Variable Modify String %Results%: Append Text String Variable (%Macroname%)

Variable Modify String %Results%: Append Text String Variable (%CRLF%)

Variable Modify Integer %Hits%: Increment

Variable Set String %OldName% to "%Macroname%"

End If

:End

Variable Modify Integer %N[1]%: Increment

Text File End Process

Text Box Display: Results List

Variable Modify String: Save %Results% to "C:\Docs\SUNDRY\Macro Express\Results.txt"

Macro Return

 

<COMMENT Value="This part gets the macro name entered as a target. It assumes you have the name selected in ME Pro Explorer."/>
<KEYSTROKE SPEED Delay="50"/>
<MOUSE RIGHT CLICK/>
<DELAY Flags="\x02" Time="100"/>
<TEXT TYPE Action="0" Text="p"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<WAIT FOR TEXT PLAYBACK Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<CLIPBOARD COPY/>
<VARIABLE SET STRING Option="\x02" Destination="%Target%"/>
<COMMENT Value="This part searches that file for all commands containing at least one Macro Run for the target macro xyz."/>
<VARIABLE SET TO ASCII CHAR Value="13" Destination="%CR%" _COMMENT="Set CR"/>
<VARIABLE SET TO ASCII CHAR Value="10" Destination="%LF%" _COMMENT="Set LF"/>
<VARIABLE SET STRING Option="\x00" Destination="%CRLF%" Value="%CR%%LF%"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%N[1]%" Value="1"/>
<TEXT FILE BEGIN PROCESS Filename="C:\\Docs\\SUNDRY\\Macro Express\\CurrentMacroScripts.txt" Start_Record="1" Process_All="TRUE" Records="1" Variable="%Text%"/>
<IF VARIABLE Variable="%Text%" Condition="\x06" Value="Name: " IgnoreCase="FALSE" _COMMENT="Test for current macro name"/>
<VARIABLE SET STRING Option="\x00" Destination="%Macroname%" Value="%Text%"/>
<VARIABLE MODIFY STRING Option="\x0A" Destination="%Macroname%" Start="1" Count="6"/>
<GOTO Name="End"/>
<END IF/>
<IF VARIABLE Variable="%Text%" Condition="\x06" Value="<MACRO RUN Use_ID=\"FALSE\" Name=\"%Target%" IgnoreCase="FALSE" _COMMENT="Test if this command is a MACRO RUN of target macro"/>
<AND/>
<IF VARIABLE Variable="%Macroname%" Condition="\x01" Value="%OldName%" IgnoreCase="FALSE" _COMMENT="Test if this command is a MACRO RUN of target macro"/>
<COMMENT Value="Do whatever is necessary for a hit"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%Results%" Variable="%Macroname%"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%Results%" Variable="%CRLF%"/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%Hits%"/>
<VARIABLE SET STRING Option="\x00" Destination="%OldName%" Value="%Macroname%"/>
<END IF/>
<LABEL Name="End"/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%N[1]%"/>
<TEXT FILE END PROCESS/>
<TEXT BOX DISPLAY Title="Results List" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red255\\green0\\blue0;}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs16 The target macro \\cf1 %Target%\r\n\\par \\cf0 is used (at least once) in the following %Hits% macro(s):\\b0 \r\n\\par \\pard \r\n\\par %Results%\r\n\\par \r\n\\par \\pard\\qc\\b These have been saved to the file Results.txt (replacing previous contents).\\b0\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="600" Height="800" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<VARIABLE MODIFY STRING Option="\x11" Destination="%Results%" Filename="C:\\Docs\\SUNDRY\\Macro Express\\Results.txt" CRLF="TRUE"/>
<MACRO RETURN/>

 

Notes/Queries

 

1. Obviously the filenames or at least their path will need changing to suit.

 

2. Here the creation takes less than a second, generating a file of 12,200 lines (for 573 macros in FULL.mex).

 

3. I'm not sure why a Script Editor window sometimes gets displayed at the end of the search, taking the focus from the message.

 

4. When I consolidated both the creation and the search into a single macro I hit an obscure snag. The macro crashes (hard - cannot be aborted except by terminating ME Pro) consistently when the search reaches

this command line:

<VARIABLE SET STRING Option="\x00" Destination="%OldName%" Value="%Macroname%"/>

That is, of course, a command in the macro that is actually running. But I still haven't fathomed exactly why it fails. I'm wondering if Joe's suggestion up-thread is relevant, but haven't really grasped how to use it in this context.

 

So the only way I can run the search part is to first delete that line of script from the text file.

 

5. The search then takes a few seconds, finishing with this message window:

 

MEPro-WhereUsedResults.jpg

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Sorry to come so late to the party, but I've been away in Europe and USA!

 

I wrote a macro some time ago that produces 2 reports, a CalledBy and a Uses report. The first lists, for each macro, all the macros it calls, while the second lists, for each macro, all the macros that call it. It's written for ME3 and, frankly, its approach probably doesn't permit it to be rewritten for ME4. It is essentially a macro that opens each macro in edit mode, then searches and counts all Macro Run instances. For one library it takes over 20 minutes to run!

 

But with multiple libraries now possible, I don't think this will work well any more.

Link to comment
Share on other sites

Sorry to come so late to the party, but I've been away in Europe and USA!

 

I wrote a macro some time ago that produces 2 reports, a CalledBy and a Uses report. The first lists, for each macro, all the macros it calls, while the second lists, for each macro, all the macros that call it. It's written for ME3 and, frankly, its approach probably doesn't permit it to be rewritten for ME4. It is essentially a macro that opens each macro in edit mode, then searches and counts all Macro Run instances. For one library it takes over 20 minutes to run!

 

But with multiple libraries now possible, I don't think this will work well any more.

 

Paul,

 

Any chance you could post or upload it please? I'd be very interested in studying your approach, although I'm committed to ME Pro now.

 

Also, any thoughts from anyone on that remaining obstacle I described please?

 

--

Terry, East Grinstead, UK

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