mIRC Home    About    Download    Register    News    Help

Print Thread
#126073 24/07/05 11:16 PM
Joined: Aug 2004
Posts: 43
J
javatis Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Aug 2004
Posts: 43
menu status,menubar {
Test It
.Do Testit: {
set %x 1
while ( %x <= 2) ) {
TIMER -m 0 3000 /msg AcertainNick %x
inc %x
}
}

^^^^^^^^^^^^^^^^^^^^^^^^^

why does this while activates hundrets of timers bevor it shuts down mirc ?

i whant to make a simple timer in milliseconds that msg a certain nichk each XXXXX milliseconds .. can someone explain me why the code above activates hundret times instead of making 2 ..->(while %x <=2) <-..

greetz

#126074 24/07/05 11:48 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
you had
Code:
menu status,menubar {
Test It
.Do Testit: {
set %x 1
while ( %x &lt;= 2) ) {
TIMER -m 0 3000 /msg AcertainNick %x
inc %x
}
}


you have while ( %x <= 2) ) <-- one extra )

you have TIMER -m 0 3000 /msg AcertainNick %x

the -m means the 3000 is miliseconds, have to ask why use the -m with 3000 as it is the same as not using the -m with 3

the reason it flooded is you have 0 for the repeat time, which is a repeat forever setting in a timer

also you didnt name the timer and while that isnt wrong it might be better to name it

lastly it was missing the closing }

see my test
Code:
menu status,menubar {
  Test It
  .Do Testit: {
    set %x 1
    while ( %x &lt;= 2) {
      TIMERmsg $+ %x 1 3 /msg $me %x
      inc %x
    }
  }
}

#126075 25/07/05 12:48 AM
Joined: Aug 2004
Posts: 43
J
javatis Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Aug 2004
Posts: 43
a timer without the -m works fine.. i still have thisone in my script at annother place.. but i maybe sometimes need 500 instead of 3000 and i dont know how to make a 0.5 or 0.7 s timer without milliseconds:)

greetz

#126076 25/07/05 12:54 AM
Joined: Aug 2004
Posts: 43
J
javatis Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Aug 2004
Posts: 43
btw ur code works fine .. like mine.. (without the -m) but i need it a milisecond timer:) and when i insert the -m and change the 3 to 3000 it activates (also with the repeatnumber 1 instead of 0) over 500 timers in a few seconds to just slow dowm mirc so that i have to quit it with taskmanager ...

#126077 25/07/05 02:13 AM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
you might have two of these like your old one and the new one, but have clicked the old one?
I tested again using the milisecond timer and have no trouble
Code:
menu status,menubar {
  Test It
  .Do Testit: {
    set %x 1
    while ( %x &lt;= 3) {
      TIMERmsg $+ %x -m 1 3000 /msg $me %x
      inc %x
    }
  }
}

results were
* Timer msg1 activated
* Timer msg2 activated
* Timer msg3 activated
* Timer msg3 halted
* Timer msg2 halted
* Timer msg1 halted

changing back to a nonmilisecond timer the results:
* Timer msg1 activated
* Timer msg2 activated
* Timer msg3 activated
* Timer msg1 halted
* Timer msg2 halted
* Timer msg3 halted

note the order in which they fire? I don't know that it matters to you
or not.

#126078 25/07/05 04:27 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
menu status,menubar {
  Test It
  .Do Testit: {
    set %x 1
    while ( %x &lt;= 3) {
      TIMERmsg $+ %x -m 1 $calc(3000 + %x * 16) /msg $me %x
      inc %x
    }
  }
}


that well fix the firing order
ticks seem to go up in increments of 15 or 16 , likely actually in 15.625 (1/64th of a second), so you increment the timer by 16ms to offset to the next value checked against.

#126079 25/07/05 08:32 AM
Joined: Aug 2004
Posts: 43
J
javatis Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Aug 2004
Posts: 43
funny both of ur´s work ...

Code:
Test it me
  .Do Testit me {
    set %xy 1
    while ( %xy &lt;= 3) ) {
      TIMERmsg $+ %xy -m 1 3000 /msg $me %xy
      inc %xy
    }
  }

Test It
  .Do Testit: {
    set %x 1
    while ( %x &lt;= 3) {
      TIMERmsg $+ %x -m 1 $calc(3000 + %x * 16) /msg $me %x
      inc %x
    }
  }


Test It2
  .Do Testit2: {
    set %x 1
    while ( %x &lt;= 3) {
      TIMERmsg $+ %x -m 1 3000 /msg $me %x
      inc %x
    }
  }
can someone explain me where the different is ??

Last edited by javatis; 25/07/05 08:34 AM.
#126080 25/07/05 11:21 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Mine and MikeChats are the same thing, infact mine is mikechats, all i did was add (%x * 16) to the 3000ms delay, this well cause the timers to go off in the same order they were created.

Yours fails becuase, as said above while ( %xy <= 3) ) { is a faulty line, you have an extra ) that needs to be removed.

#126081 25/07/05 11:36 AM
Joined: Aug 2004
Posts: 43
J
javatis Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Aug 2004
Posts: 43
hhhh thx... and sorry i was blind ....

thx for the help

greetz

#126082 25/07/05 04:20 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
you might compare using the repeat function of timers to doing the loop.
Code:
menu status,menubar {
  Test It 
  .Do &amp;Repeat:timermsg -m 2 3000 echo -a Test Repeat $!asctime(ss)
  .Do Test &amp;Loop: {
    set %x 1
    while ( %x &lt;= 2) {
      TIMERmsg $+ %x -m 1 $calc(3000 + %x * 16) echo -a Test Loop %x $asctime(ss)
      inc %x
    }
  }
}


Results:
echos the seconds, 3 seconds apart
* Timer msg activated
Test Repeat 57
Test Repeat 00
* Timer msg halted

they all finish "at the same time" well 16 miliseconds apart smile
* Timer msg1 activated
* Timer msg2 activated
Test Loop 1 11
* Timer msg1 halted
Test Loop 2 11
* Timer msg2 halted


Link Copied to Clipboard