Jump to content
Macro Express Forums

Beware of Clear Variables with large arrays


Recommended Posts

I have a simple macro with the single command "Clear Variables" and a single array variable with a million elements. It takes 18 seconds to run. So if you have large arrays beware that this command can effect performance.

 

I don’t usually use this command but in this case I wanted to run the macro again in order to check for any new file arrivals since execution. You see the activation is Dir Mod so if a new file arrived while processing the current file it would not reactivate. Also one cannot use Macro Run to re-execute the selfsame macro. But I wanted to ensure all my variables were clean for the rerun. I guess I'll have to go thru variable by variable and decide which really need to be cleared and in the case of the array only clear the range that are used.

 

In any case there's no question here, just wanted to let people know about it.

Link to comment
Share on other sites

Also one cannot use Macro Run to re-execute the selfsame macro.

Well, that's what the documentation claims. But it ain't so!

Try this:

Variable Modify Integer %n[1]%: Increment
If Variable %n[1]% Is Greater Than "3"
 Macro Return
End If
Text Box Display: 
Macro Run: TestRecursive
Text Box Display:

<VARIABLE MODIFY INTEGER Option="\x07" Destination="%n[1]%"/>
<IF VARIABLE Variable="%n[1]%" Condition="\x03" Value="3" IgnoreCase="FALSE"/>
<MACRO RETURN/>
<END IF/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Starting Recursive macro %n[1]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO RUN Use_ID="FALSE" Name="TestRecursive" ID="-1" Wait="TRUE"/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Ending Recursive macro %n[1]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

I get this result:

Starting Recursive macro 1

Starting Recursive macro 2

Starting Recursive macro 3

Ending Recursive macro 4

Ending Recursive macro 4

Ending Recursive macro 4

 

which is correct if recursion is allowed.

Link to comment
Share on other sites

That's interesting. I created a test macro very similar to that. Except all it did was increment and display. What I found was that when run from F9 it would run twice and mysteriously that's all. Run from the Macro Explorer it would run only once. I wonder why your results are different.

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