mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 37
D
druiddk Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 37
Okay so i have a window called @PRE-TIME with 4 lines:

This a cut from my code:

Code:
var %window-close = 10
.dec -c %window-close
while (%window-close > 0) {
   .rline @PRE-TIME 4 This window will close in: %window-close seconds
}
.window -c @PRE-TIME
 

Joined: Dec 2002
Posts: 212
V
Fjord artisan
Offline
Fjord artisan
V
Joined: Dec 2002
Posts: 212
Post deleted by vasil_michev


And all I need now is intellectual intercourse, a soul to dig the hole much deeper
Joined: Feb 2003
Posts: 37
D
druiddk Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 37
Uhmn... but if i but the /dec inside the loop it will be executed every time it runs trough the loop ?!

I used dec -c because I only want it to decrease by 1 per second.

Btw i forgot to unset %window-close after closing the window but that will be done as well of course.

Joined: Dec 2002
Posts: 212
V
Fjord artisan
Offline
Fjord artisan
V
Joined: Dec 2002
Posts: 212
sorry, I've missed the -c part smile
Althought i'm not sure if this works,even if it does for those 10 secs mIRC will do a great number of itterations, and that's the reason for this "crash" (which may be just a huge slowdown)
why don't you use a timer to do that?
use %!window-close to reevaluate the variable, I've got something like this and it works fine


And all I need now is intellectual intercourse, a soul to dig the hole much deeper
Joined: Feb 2003
Posts: 37
D
druiddk Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 37
OK u gave me the idea :P

But I cant get the %!window-close to work :-(

Heres the new
Code:
      .set %window-close 10
      .aline @PRE-TIME This window will close in: %window-close seconds
      .dec -c %window-close
      .timerupdatepretime 9 1 .rline @PRE-TIME 4 This window will close in: %!window-close seconds
      .timerclose 1 10 .window -c @PRE-TIME
      .timerunset 1 10 .unset %window-close
 


The 4th line will just be:

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
What you did can't work because mirc cannot process anything else if a routine isn't finished. So it can't /dec the variable once a sec because until the routine is finished (which would happen after the while loop finishes) mirc can't do anything else. But if the variable cannot be /dec'ed, the loop will never terminate... it's a dead end.

You'd better use timers for what you want. There is a way to do it in the loop, by checking $ctime ($ctime's value changes because it's independant of mirc), with something like this:
Code:
  var %c = $ctime
  while $calc(10 - $ctime + %c) {
    .rline @PRE-TIME 4 This window will close in: $ifmatch seconds
  }
but I wouldn't use it because mirc remains frozen for 10 secs, while /timer's do not freeze mirc.

Last edited by qwerty; 22/02/03 07:46 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Dec 2002
Posts: 212
V
Fjord artisan
Offline
Fjord artisan
V
Joined: Dec 2002
Posts: 212
Code:
alias blabla1 {
  window @pre-time
  set %timeremaining 10 
  .timerblabla 10 1 dostuff
}
alias -l dostuff {
  dec %timeremaining
  if (%timeremaining) { .aline @PRE-TIME This window will close in: %timeremaining seconds | return }
  window -c @PRE-TIME
}  


And all I need now is intellectual intercourse, a soul to dig the hole much deeper
Joined: Feb 2003
Posts: 37
D
druiddk Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 37
Ok qwerty... I already decided to use a timer instead, but I cant figure how to make it update %window-close in the .rline it keeps at a constant "9" not showing the decrease...

Do I really need to make 9 timers? :-/

Joined: Dec 2002
Posts: 212
V
Fjord artisan
Offline
Fjord artisan
V
Joined: Dec 2002
Posts: 212
blah, there's no need to use !%variable smile


And all I need now is intellectual intercourse, a soul to dig the hole much deeper
Joined: Dec 2002
Posts: 68
P
Babel fish
Offline
Babel fish
P
Joined: Dec 2002
Posts: 68
To stop a loop so it doesn't crash mIRC. Use the Break key (by Scroll Lock). It may be, Shift+Break, Alt+Break, Ctrl+Break, or just Break. I forget.

Joined: Feb 2003
Posts: 37
D
druiddk Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 37

Vasil: well it doesnt work :-/

With the timer it updates the window with the same number (9) 9 times... I need it to look at the variable every time it runs the timer mhmm...

Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Code:
  set %timeremaining 10
  rline @PRE-TIME 4 This window will close in 10 seconds
  .timer 10 1 dec %timeremaining $chr(124) rline @PRE-TIME 4 This window will close in $!eval(%timeremaining,2) seconds $chr(124) if ( $!eval(%timeremaining,2) == 0 ) { window -c @PRE-TIME }
Here's the script I tested it with...
Code:
alias PRE-TIME {
  window @PRE-TIME
  aline @PRE-TIME Line1
  aline @PRE-TIME Line2
  aline @PRE-TIME Line3
  aline @PRE-TIME Line4
  set %timeremaining 10
  rline @PRE-TIME 4 This window will close in 10 seconds
  .timer 10 1 dec %timeremaining $chr(124) rline @PRE-TIME 4 This window will close in $!eval(%timeremaining,2) seconds $chr(124) if ( $!eval(%timeremaining,2) == 0 ) { window -c @PRE-TIME }
}
Messy, but works..

Joined: Feb 2003
Posts: 37
D
druiddk Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 37

ALL HAIL Collective :-)~~

YOU LIFESAVER! Hehe! Thank you soooo much!

Joined: Dec 2002
Posts: 212
V
Fjord artisan
Offline
Fjord artisan
V
Joined: Dec 2002
Posts: 212
well it sure does work for me wink
perhaps you've changed something, or you're using older version of mirc?


And all I need now is intellectual intercourse, a soul to dig the hole much deeper

Link Copied to Clipboard