mIRC Homepage
Posted By: quartz adding a visual counter on a %loop - 29/03/20 03:32 PM
I have a standard %loop reading lines from a txt file, there are (at the moment) 35,000 lines in the file

so the %loop is very rapid. in the loop, if I put " /echo -s %loop " in each loop (or pref updating a single line of a @window), mIRC stops the update message after 3-4-500 lines (continues to run the script). presumably the /echo takes second priority to running the script (or something)

is there any way to set it so mIRC will make sure it continues to run (display) the /echo line?
Posted By: JohnEricNO Re: adding a visual counter on a %loop - 29/03/20 06:29 PM
You should explore the /play command. It much more versatile in how txt files are accessed and displayed.
Posted By: KindOne Re: adding a visual counter on a %loop - 29/03/20 06:55 PM
The /echo command is still running. mIRC is single threaded so if the while loop is large enough it will freeze the UI and everything else while it does the loop.

Using /echo during a while loop slows it down if its being printed into a window. It will drastically slow down if its being printed in the active window.

After the while loop is done you can scroll up the window and see everything.

Code
; No Echo.
//var %a $ctime | var %x 100000 | while (%x) { dec %x } | echo -ag Time: $calc($ctime - %a) seconds.
Time: 1 seconds.

; Echo into status window while looking at another window.
//var %a $ctime | var %x 100000 | while (%x) { echo -sg %x | dec %x } | echo -ag Time: $calc($ctime - %a) seconds.
Time: 8 seconds.

; Echo into active window.
//var %a $ctime | var %x 100000 | while (%x) { echo -ag %x | dec %x } | echo -ag Time: $calc($ctime - %a) seconds.
Time: 127 seconds.
Posted By: quartz Re: adding a visual counter on a %loop - 29/03/20 09:22 PM
thanx all

ok the while loop still seems to freeze echo'ing after a few 100 lines

thanks John, I dont think the /play will do what I want it to at the moment tho

basically it's a log file, and i'm scanning the log file [line by line], for instances of a certain string, every time the string exists, it increments a %counter

tbh I don't mind it actually taking longer, but it would be nice to see a progress number
Posted By: Wims Re: adding a visual counter on a %loop - 29/03/20 09:54 PM
The command /fupdate may help displaying the lines at a different pace, therefore preventing windows from getting unresponsive, try /fupdate 100 for example.

https://en.wikichip.org/wiki/mirc/commands/fupdate
Posted By: JohnEricNO Re: adding a visual counter on a %loop - 29/03/20 10:09 PM
If it's just matches and a match count you want, use /filter and $filtered.
Posted By: quartz Re: adding a visual counter on a %loop - 30/03/20 12:06 AM
that cool. filter definitely works.

not as much fun as a loop counter tho wink
Posted By: quartz Re: adding a visual counter on a %loop - 30/03/20 10:25 AM
will check /fupdate
Posted By: quartz Re: adding a visual counter on a %loop - 31/03/20 07:32 PM
ok so done a couple test ones

a small %loop going up to 2,000, where the visual counter freezes after about 500, takes "5,000 ticks", and mIRC runs at full 25% cpu

running the command on a millisecond /timer -m, takes about 30,000 ticks, and takes about 4% cpu

on a /timer -h, take about 10,000 ticks, and takes about 12% cpu

so tbh, using a /timer -h seems to be a good option here, only takes twice as long as a %loop , and gives a fully up to date counter

I mean actually /filter is the "functional" solution, but /timer -h also works
Posted By: Wims Re: adding a visual counter on a %loop - 31/03/20 08:00 PM
If you want display a counter and you expect hundreds of matches over 35000 lines, echoing one line to a window is not very good, you could use a dialog and a text button that you increase, or a picture window allow you to create your own progress bar, or simply display the number.
© mIRC Discussion Forums