mIRC Home    About    Download    Register    News    Help

Print Thread
/dec -z #143525 25/02/06 06:08 PM
Joined: Jun 2003
Posts: 23
V
vakuum Offline OP
Ameglian cow
OP Offline
Ameglian cow
V
Joined: Jun 2003
Posts: 23
There's something strange in the way /dec -z works. Here are some examples, with results. Do them yourself if you dont believe me. I'm using 6.16 but it has been tested on 6.17 too.

Code:
//set %x 6 | echo -a %x | dec -z %x 2 | echo -a %x | .timer 3 1 echo -a $eval(%x,0) 
6
4
2
1
* /echo: insufficient parameters

//set %x 8 | echo -a %x | dec -z %x 4 | echo -a %x | .timer 3 1 echo -a $eval(%x,0)
8
4
2
1
* /echo: insufficient parameters


#HelpDesk @ DALnet
Re: /dec -z #143526 25/02/06 11:38 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
There is nothing wrong with that, its due to the way things work in mirc
When you set up a -z on a variable it decreases by one at the turn of the next second, AND if you set up a timer to go off once a second, it also goes off at the turn of the second (folowing -z being done) HOWEVER if the second that your in has less than around 90% of it left at the time u set the timer it well not go off at that second change over, but at the next.

example
At 12:00:00.250 u do a /dec -z %x then at 12:00:01.000 %x well be decreased
At 12:00:00.250 u do a /timer 3 1 echo %x then at 12:00:02.000, 12:00:03.000 & 12:00:03.000 this well go off

This is the cause of your initial double decreament, the -z goes off while the timer is delayed to the next cycle.

Using the -s option to display the effects of the /SET and /DEC you can see whats happening a bit clearer. and the -t opetion of echo
(i have a custom timer running producing to the ms timestamps so you well not be able to reproduce the exactness in your /echo -t)

//var %ticks = $ticks | set -s %x 6 | echo -at %x , ticks = $calc($ticks - $ticks) | dec -sz %x 2 | echo -at %x , ticks = $calc($ticks - $ticks) | .timer 3 1 echo -at $eval(%x,0) , ticks = $!calc($ticks - %ticks )

* Set %x to 6
[12:14:42.719] 6 , ticks = 0
* Dec %x to 4
[12:14:42.719] 4 , ticks = 0
* Dec %x to 3 12:14:43.188
* Dec %x to 2 12:14:44.188
[12:14:44.188] 2 , ticks = 1484
* Dec %x to 1 12:14:45.188
[12:14:45.188] 1 , ticks = 2484
* Unset %x 12:14:45.188
[12:14:46.188] , ticks = 3484

The red timming values were added to show when the auto dec and unsets occured.

As you can see the -z decrment and the timers are going off 0.188 seconds after the second, rather than at .000, this is likely due to other activities mirc is also doing going before them, but essentially, its a regulated time.
Notice the first dec of %x occurs as 42 seconds rolls to 43, but the first timer event only goes off at 43 rolling to 44 (after the 2nd dec %x).
The ticks count shows you that the first timer event went off 1.484 seconds after the timer was created, but following events went off 1 second after each other.


*** dont know if u needed this but incase ***
If your dec -z a value and also wanting to display its count down, I would suggest you simply do soemthing like this

//set -s %x 6 | echo -a %x | dec %x 2 | echo -a %x | .timer 3 1 dec %x $(|,) echo -at $eval(%x,0)

$(|,) creates a command sepearator inside the timer command, its the same as your $eval(%x,0)

Re: /dec -z #143527 16/04/06 01:39 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
Your post explains absolutely nothing about a) why mIRC first decreases the variable by 4 and b) why the timer is running slower than /dec -z EVERY time.