samacro Posted February 24, 2019 Report Share Posted February 24, 2019 I want Macro Express to repeat an operation 2 million times. During the working of system, I want to know how many times is that operation done. Is it possible to show repeat number on the screen while macro is working? Quote Link to comment Share on other sites More sharing options...
Cory Posted February 24, 2019 Report Share Posted February 24, 2019 Yes. Text Box Display with the option of until close or end of macro. Then Text Box Update. Quote Link to comment Share on other sites More sharing options...
acantor Posted February 25, 2019 Report Share Posted February 25, 2019 Displaying each iteration might slow down the macro. Alternatively, the macro might run so quickly that the numbers don't have sufficient time to display. You'll need to experiment to find out! Variable Set Integer %Count% to 1 Text Box Display: Test Repeat Start (Repeat 1000 times) Text Box Update: Test Variable Modify Integer %Count%: Increment Delay: 5 milliseconds End Repeat <VARIABLE SET INTEGER Option="\x00" Destination="%Count%" Value="1"/> <TEXT BOX DISPLAY Title="Test" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\b\\f0\\fs28 %Count%\\b0\\fs20 \r\n\\par }\r\n" Left="701" Top="409" Width="116" Height="103" Monitor="0" OnTop="TRUE" Keep_Focus="FALSE" Mode="\x01" Delay="0"/> <REPEAT START Start="1" Step="1" Count="1000" Save="FALSE"/> <TEXT BOX UPDATE Header="Test" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\b\\f0\\fs28 %Count%\\b0\\fs20 \r\n\\par }\r\n"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%Count%"/> <DELAY Flags="\x02" Time="5"/> <END REPEAT/> Quote Link to comment Share on other sites More sharing options...
Samrae Posted February 25, 2019 Report Share Posted February 25, 2019 As acantor said, displaying each iteration will slow down the macro. When I have a long macro I update the iteration counter every 25, 50, 100 or 1000 times. Yes, experiment to decide what you like best. Text Box Display: Test Variable Set Integer %DispCount% to 0 Variable Set Integer %DispInterval% to 25 Repeat Start (Repeat 100000 times) Variable Modify Integer %DispCount%: Increment If Variable %DispCount% Is Greater Than or Equal To "%DispInterval%" Text Box Update: Test Variable Set Integer %DispCount% to 0 End If End Repeat <TEXT BOX DISPLAY Title="Test" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\b\\f0\\fs28 %Count%\\b0\\fs20 \r\n\\par }\r\n" Left="701" Top="409" Width="116" Height="103" Monitor="0" OnTop="TRUE" Keep_Focus="FALSE" Mode="\x01" Delay="0"/> <VARIABLE SET INTEGER Option="\x00" Destination="%DispCount%" Value="0"/> <VARIABLE SET INTEGER Option="\x00" Destination="%DispInterval%" Value="25"/> <REPEAT START Start="1" Step="1" Count="100000" Save="TRUE" Variable="%Count%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%DispCount%"/> <IF VARIABLE Variable="%DispCount%" Condition="\x04" Value="%DispInterval%" IgnoreCase="FALSE"/> <TEXT BOX UPDATE Header="Test" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\b\\f0\\fs28 %Count%\\b0\\fs20 \r\n\\par }\r\n"/> <VARIABLE SET INTEGER Option="\x00" Destination="%DispCount%" Value="0"/> <END IF/> <END REPEAT/> Also, instead of managing the repeat counter %Count% I suggest you tick the box in the Repeat Start command and enter %Count% there. Quote Link to comment Share on other sites More sharing options...
acantor Posted February 25, 2019 Report Share Posted February 25, 2019 These macros are often about compromises. If you display a box showing a number every iteration, the macro will run more slowly. Perhaps this would not be significant if you are only looping a thousand times, but it could be an issue for you, since you want to do 2 million loops. If you want to update the message every (for example) 1000 loops, you will need to add steps. This could involve changing your integer variable to a decimal variable, dividing it, extracting the non-integer portion, and then checking that value. You can be sure that all of these steps will slow down your macro. So much depends on what your script will be doing and which version of Windows you're using. A loop that does nothing (other than repeat 2 million times) executes in about five or six seconds (at least on my computer). A loop that compares pixel colours at different points in the screen might run too slow to be practical, especially in Windows 10. 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.