mIRC Home    About    Download    Register    News    Help

Print Thread
#103895 27/11/04 04:10 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I was just recoding a script i had written that started to bog down time wise when its dealing with 1000's of files, it checks if a sent file already exists and redirects the download to that files location if the send is longer, well anyway, i couldnt actually use what came to mind while doing it, but heres what i was thinking about.

I know (suspect) it would be quite hard to make mirc multithreading, so i beleive most scripts well always have to run to completion before control is handed back.
What if there was a command (/yield) that said "ok lets stop the script here & start a timer to resume here when it reaches zero & pass control back", mirc then can deal with any pending events etc, and then the timer goes off after them.

I said a timer becuase thats currently how i deal with any large levels of looping, ill just set a timer off using "/timer 1 0 aliasname" then that alias does what ever and if it would normally loop back it calls itself using he same /timer 1 0 system.
This allows mirc to catch up on anything its needing to do, and still process my loop.

I do accept that a command in the center of a script doing it could run into problems, the most obvious is the same script being called during a /yeild.
That could be of course mentioned in a warning to use this with care, or any occurances of the same /yeild command being encountered well be ignored, so the subsequent calling of a script would just countinue to run.

PS: im sure there are problems with this, just throwing it out as an idea.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Actually, a /yield command wouldn't be too hard to implement, if it uses an approach similar to whilefix.dll. That dll is working great for me so far and it's just three lines of code smile


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
lol, i actually wrote a script to do that but decided not to post it as it didn't work right as i used a number in the loop rather than $ticks:

alias wait {
var %time $calc($ticks + $1)
while (%time > $ticks) {
dll WhileFix.dll WhileFix
}
return
}

Usage: /wait time in miliseconds

Sample:

alias testingwhile {
echo -a next line should be in 15 seconds time
var %b $ticks
wait 15000
echo -a $calc($ticks - %b) ms later ( $+ $calc(($ticks - %b)/1000) seconds)
}

you MUST have whilefix.dll in your mIRC dir for this to work else it will FREEZE mIRC for 15 seconds. whilefix.dll prevents mIRC freezing and means you can type, join channels, trigger aliases etc without any problems.

Altho, it might be a nice to have a proper inbuilt command that did this.

Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I just downloaded whilefix, but havent tried it yet.

What would be the liekly outcome of renetering the same alias that was running it? any ideas?

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
If I understood you correctly, an alias (using whilefix or not) cannot call itself directly, but an alias can call another one, which in turn calls the first. The commands are put in a stack, so, for example, if the alias /one uses whilefix and calls /two (that also uses whilefix), the execution of /one is suspended until /two finishes, then /one continues from where it had stopped. mirc processes window messages normally during the whole thing.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
i was meaning more like user types in /RUNMEALIAS
and while its running types in /RUNMEALIAS again.
(simplest senario shown above i can amagine event driven occurances of it)

Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
if you try and do /testingwhile twice, then it will return after the last loop has finished, so it if you do a /testingwhile, then wait 10 seconds, and do it again, both will return 15 seconds after the 2nd /testingwhile.

So basically, if you want to do more than 1 wait and they might conflict, copy and paste the wait alias again and rename it to wait1 or wait2 etc etc

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Same thing, the new /runmealias kicks in and the old /runmealias is suspended until the new one is finished.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
hhmm, disregard my last posts solution cuz it doesn't work...

this is supposed to work but it doesn't for me.

Joined: Nov 2004
Posts: 842
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 842
doesn't mIRC have an option of pausing with timers?


What do you do at the end of the world? Are you busy? Will you save us?
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
i wasnt trying to pause, im trying to not freeze mirc.


Link Copied to Clipboard