mIRC Home    About    Download    Register    News    Help

Print Thread
#66379 03/01/04 05:11 PM
Joined: Dec 2003
Posts: 33
M
Man Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Dec 2003
Posts: 33
If you were to set a timer to perform a command in a while loop

eg:
Code:
alias test {
  var %test 20
  while (%test) {
    .timertesting $+ %test 1 0 echo -s %test
    dec %test
  }

}


Here the varible %test decreases after each loop of while. So the expected result would be.

20
19
18
...

But instead its

1
2
3
...

The timers are executing in the reverse order in which they were called, for simple tasks this isn't a problem but when they get bigger it is expected that the first thing you call would happen before the last thing you call to the timer.

#66380 04/01/04 06:55 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
heres where your problem is " it is expected ", i dont see thats the case, your asking for everything in your example to be done as soon as this script is finished, each one has an identical priority (time before execution), timers are simply a list of events coming up, if i was given 20 pieces of paper each one had something to do next, the last one i would be given is on the top, so its the first one i do next, then i work my way back. "I expect" (becuase it is currently this way) this to remain as is, I checked how these events were ordered and took note of it, and have used it, for some things, such as Printing totals at the top of a results list rather than the bottom. If u need the events to go of in a particular order then script it to do all of them on one timer. And dont tell me thats not possable as its totally possable, you just store the commands and issue them in order of storage.

PS : identical priority (time before execution) was my explanation of order, chnaging the timer before execution, may/may not correct your problem (microsecond timers wont always execute in order of there time, but rather if there time has expired they go off)

#66381 04/01/04 07:43 AM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I suppose Khaled could simply use an FIFO stack instead of an FILO stack. I can't see that being a very difficult change. I'd say this is a valid "bug report" and worthy of consideration.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#66382 04/01/04 03:14 PM
Joined: Dec 2003
Posts: 33
M
Man Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Dec 2003
Posts: 33
Sorry I accidently left out something, It performs it in the order alphabeticly/numercly, ie 1,2,3,4,5,6,7,8,9,10 or a,b,c

so timera will come first and timerz last

Its not to do with the order im sending them in, but the names I give the timers, this isn't very helpful .

I originally thought it had to do with the while loop, but figured out it wasn't, as

Code:
alias test {
  .timerzzz 1 0 set %geeze ahhh
  .timeraaa 1 0 echo -s %geeze
}


the echo will fail, as %geeze doesn't get set until AFTER it has been performed, even though the timerzzz was called first, timeraaa will run first.

#66383 05/01/04 02:29 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I "now" dont think its either of them actually, another post told me it used a alpha numeric ordering to trigger events, so i checked this out, and it didnt seem to hold true to that either, in fact i cant find any particular pattern. give this code a try.
Code:
 
test1 {
  var %t = ABCDEFGHIJ1234567890
  var %i = 20
  var %c
  while (%i) {
    var %p = $rand(1,$len(%t))
    .timer $+ $mid(%t,%p,1) 1 0 check1 $mid(%t,%p,1)
    %c = %c $mid(%t,%p,1)
    %t = $left(%t,$calc(%p - 1)) $+ $mid(%t,$calc(%p + 1))
    dec %i
  }
  var %t 
  var %i = $timer(0)
  while (%i) {
    %t = $timer(%i) %t
    dec %i
  }
  echo Timer TIMER() Order (First to Last) %t
  echo Timer Created Order (First to Last) %c
  set %check1.created %c
  set %check1.recover

}
check1 {
  set %check1.recover $1 %check1.recover
  if ($len(%check1.recover) == 39) {
    if (%check1.created != %check1.recover) {
      echo Timer Recover Order (Last to First) %check1.recover (NON MATCHED)
    }
    else {
      echo Timer Recover Order (Last to First) %check1.recover 
    }
    unset %check1.created
    unset %checkx.recover
    echo .
  }
}
 


heres the results of two runs of /test1
Timer TIMER() Order (First to Last) 0 1 2 3 4 5 6 7 g a e j 8 9 i b c f d h
Timer Created Order (First to Last) 7 G A 1 3 0 E J 9 I B C 4 2 5 6 F D H 8
Timer Recover Order (Last to First) 7 G A 1 0 E J 9 I B C 4 2 5 6 F D H 8 3 (NON MATCHED)
.
Timer TIMER() Order (First to Last) 0 1 2 3 4 5 e g b i h 6 7 8 9 f d a j c
Timer Created Order (First to Last) 5 E G B I H 9 3 2 7 F D 0 A 1 J 4 C 6 8
Timer Recover Order (Last to First) 5 E G B I H 9 3 2 7 F D 0 A 1 J 4 C 6 8
.

Sometimes it matches sometimes it doesnt, sometimes matching for ages others not matching for ages etc. no pattern to it, also the mismatch isnt only one sometimes there all outa sync.
I have a feeling there are other factors beyond a scripters control that effects the timer execution order.

#66384 05/01/04 02:56 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
that doesnt make it alpha ordered, theres two problems with that TEST alias
(1) In '.timeraaa 1 0 echo -s %geeze' the %geeze gets evaluated then and there not in the timer it should read '.timeraaa 1 0 echo -s % $+ geeze'
(2) The '.timeraaa 1 0 echo -s %geeze' if it was correct is last timer and you have already expressed that its last in first out.

Check out this code
Code:
 
test.0 {
   unset %geeze
  .timeraaa 1 0 echo -s aaa 0 % $+ geeze
  .timerccc 1 0 set %geeze ahhh
  .timerbbb 1 0 echo -s bbb 0 % $+ geeze
}
test.1 {
   unset %geeze
  .timeraaa 1 1 echo -s aaa 1 % $+ geeze
  .timerccc 1 1 set %geeze ahhh
  .timerbbb 1 1 echo -s bbb 1 % $+ geeze
}
 


results
/test.0
bbb 0
aaa 0 ahhh
/test.1
aaa 1
bbb 1 ahhh

From this it would appear that the timers may get placed into a order of creation, but if there expected to go off instantly, they may go off in last in first out order (im not sure if that holds either for instantly running timers see my other message)

#66385 23/01/04 11:39 PM
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
This appears to be a Windows issue with milli-second timers; regardless of the order timers are created, Windows triggers them in a random order if their trigger times are close.

If ordering is important, you could try using the /timer -h switch for a high resolution multi-media timer which seems seems to trigger timers in the order they were created.


Link Copied to Clipboard