Jump to content
Macro Express Forums

Show Number of Repeats


fug5333
 Share

Recommended Posts

I have a macro running just fine and everything works. It has a repeat function in there. I'd like to add a feature. I would like it to show me how many times it's repeated, or what repeat it is on, so to speak. A little text box that shows what it is on. I have two monitors, so the placement is not critical, but don't need it to stop the macro like a standard textbox does. Is this possible?

 

Thanks

Link to comment
Share on other sites

It's quite easy but more difficult than in ME Pro where you can update a Text Box Display. If the counter is in a variable say %N2% you use that. If you want to use your own variable, set it to 1 before going into the loop and increment by 1 before the end of the repeat loop. If you want repeats to finish the loop, you will have to add some maths for that (total number of repeats - repeats finished).

 

There are several methods depending on the speed of the loop:

 

1. Let's say the loop takes 5 secs. You can add a Timed Floating Box for say 3 secs. Each time through it will show the value of %N2% for 3 secs, be off for about 2 secs and re-appear next time through. If the display time is longer than the repeat time, you will accumulate a pile of Text Box Displays!

 

2. For faster loops you can still add Text Box Displays; they will slow the loop down slightly. Create a Floating Box - must have a Box Header title. Duplicate and go back to the first box. Change to Close Text Box. Every time you go through the loop, any existing box will be closed, followed by the new box opening. You can use this method for 1. too.

 

3. If the loop is too fast to read, have an If group of commands so the Text Box Display only appears, say, every 100 repeats (and could be a Timed Floating Box). The logic for doing that will slow things down.

 

To clear the final Text Box display for the last two methods, copy and paste the Close Text Box after the repeat loop.

Link to comment
Share on other sites

It's quite easy but more difficult than in ME Pro where you can update a Text Box Display. If the counter is in a variable say %N2% you use that. If you want to use your own variable, set it to 1 before going into the loop and increment by 1 before the end of the repeat loop. If you want repeats to finish the loop, you will have to add some maths for that (total number of repeats - repeats finished).

 

There are several methods depending on the speed of the loop:

 

1. Let's say the loop takes 5 secs. You can add a Timed Floating Box for say 3 secs. Each time through it will show the value of %N2% for 3 secs, be off for about 2 secs and re-appear next time through. If the display time is longer than the repeat time, you will accumulate a pile of Text Box Displays!

 

2. For faster loops you can still add Text Box Displays; they will slow the loop down slightly. Create a Floating Box - must have a Box Header title. Duplicate and go back to the first box. Change to Close Text Box. Every time you go through the loop, any existing box will be closed, followed by the new box opening. You can use this method for 1. too.

 

3. If the loop is too fast to read, have an If group of commands so the Text Box Display only appears, say, every 100 repeats (and could be a Timed Floating Box). The logic for doing that will slow things down.

 

To clear the final Text Box display for the last two methods, copy and paste the Close Text Box after the repeat loop.

Fairly new at this. :/ I follow the logic, but can't find a way to put that into something ME understands. Could you give an example?

 

Thanks!

Link to comment
Share on other sites

You seem to know what a Repeat and Text Box Display are (and apparently have used them). That's all you need to know. Between the Help in ME (which is excellent, with examples) and browsing the command list it should not have been very difficult.

 

Repeat Start (Repeat 10 times)
 Text Box Close: Repeat Counter Macro
 Text Box Display: Repeat Counter Macro
 Sound Beep
 Delay 3 Seconds
Repeat End
Text Box Close: Repeat Counter Macro

<REP3:01:000001:000001:00010:1:02:><TBCLOSE:Repeat Counter Macro><TBOX4:T:3:CenterCenter000175000097:000:Repeat Counter Macro
This is repeat number: %N2%><BEEP><DELAY:3><ENDREP><TBCLOSE:Repeat Counter Macro>

 

If pasting the Direct Editor code does not work you will have to enter the Scripting Editor commands manually

Link to comment
Share on other sites

There's actually a better way of doing this in ME3 unless you don't mind the flickering the above method causes by closing then reopening the text box display in lines 2 and 3.

 

I used the following method in ME3, which results in a flicker-free and continuous display of changing data.

 

I'll write this in pseudo-code - you should find this easy to convert to real code. Note that you will be using 2 almost identical text boxes, the only difference between them being the value of the Repeat No.:

Set %N91% = Number of repeats (I use %N91% and higher so as not to interfere with variables you might already be using)
Set %N92% = 1
Repeat until %N91% = 0
 Text Box Display: Progress (Repeat no. %N92%)
 If Window "Progress (Repeat no. %N93%)" is running
Text Box Close "Progress (Repeat no. %N93%)"
 End If
 If Not Window "Progress (Repeat no. %N92%)" is running
Macro Stop
 Else
Decrement %N91%
Set %N93% = %N92%
Increment %N92%
 End If
End Repeat

- It's vital to have a changing variable value as part of your text box header.

- Unless you want to display other stuff, you can make the height just enough for the header only.

- The 1st loop won't find the window referred to in line 5 since %N93% will be 0.

- The 2nd loop will create a new window showing "Repeat no. 2" since N92 has been incremented from 1 to 2 with this new window entirely covering the old one, then close the old window showing "Repeat no. 1".

etc.

 

If your loop executes quickly, you might want to insert a delay of 500ms after line 4.

Note that if the user closes the text box, the macro will stop (behaviour you can easily change).

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