mIRC Home    About    Download    Register    News    Help

Print Thread
adding a visual counter on a %loop #267054 29/03/20 03:32 PM
Joined: Dec 2019
Posts: 22
Q
quartz Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Dec 2019
Posts: 22
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?

Last edited by quartz; 29/03/20 09:06 PM.
Re: adding a visual counter on a %loop [Re: quartz] #267056 29/03/20 06:29 PM
Joined: Dec 2011
Posts: 15
J
JohnEricNO Offline
Pikka bird
Offline
Pikka bird
J
Joined: Dec 2011
Posts: 15
You should explore the /play command. It much more versatile in how txt files are accessed and displayed.

Re: adding a visual counter on a %loop [Re: quartz] #267057 29/03/20 06:55 PM
Joined: Feb 2011
Posts: 356
K
KindOne Offline
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 356
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.


irc.swiftirc.net #msl (mIRC Scripting Language)
Re: adding a visual counter on a %loop [Re: KindOne] #267060 29/03/20 09:22 PM
Joined: Dec 2019
Posts: 22
Q
quartz Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Dec 2019
Posts: 22
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

Last edited by quartz; 29/03/20 09:23 PM.
Re: adding a visual counter on a %loop [Re: quartz] #267061 29/03/20 09:54 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: adding a visual counter on a %loop [Re: quartz] #267062 29/03/20 10:09 PM
Joined: Dec 2011
Posts: 15
J
JohnEricNO Offline
Pikka bird
Offline
Pikka bird
J
Joined: Dec 2011
Posts: 15
If it's just matches and a match count you want, use /filter and $filtered.

Re: adding a visual counter on a %loop [Re: JohnEricNO] #267065 30/03/20 12:06 AM
Joined: Dec 2019
Posts: 22
Q
quartz Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Dec 2019
Posts: 22
that cool. filter definitely works.

not as much fun as a loop counter tho wink

Re: adding a visual counter on a %loop [Re: quartz] #267068 30/03/20 10:25 AM
Joined: Dec 2019
Posts: 22
Q
quartz Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Dec 2019
Posts: 22
will check /fupdate

Re: adding a visual counter on a %loop [Re: quartz] #267082 31/03/20 07:32 PM
Joined: Dec 2019
Posts: 22
Q
quartz Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Dec 2019
Posts: 22
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

Last edited by quartz; 31/03/20 07:36 PM.
Re: adding a visual counter on a %loop [Re: quartz] #267083 31/03/20 08:00 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net