Jump to content
Macro Express Forums

How to show number of repeat counter on the screen?


Recommended Posts

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

 

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
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...