mIRC Homepage
Posted By: Zed $timer() with number as timer id - 18/02/10 01:57 PM
When a timer id is a number instead of text, $timer() doesn't work.

Try these 2 lines (in a status window) and you'll see what I mean:

//.timertest 1 1 echo -gs timer: $!ctimer - $!timer($ctimer) - $!timer($ctimer).com -- "test"
//.timer777 1 1 echo -gs timer: $!ctimer - $!timer($ctimer) - $!timer($ctimer).com -- "777"
Posted By: Horstl Re: $timer() with number as timer id - 18/02/10 02:54 PM
Originally Posted By: /help $timer
$timer(N/name)
Returns the timer id of the Nth timer in the timers list. You can also specify a timer name instead of a number.
It's thus no bug but rather by design. Simply dont use a N as the timer name if you're ever going to use that identifier smile

It's like naming an alias N and using it as a custom identifier:
Code:
alias 777 { $iif($isid,return,echo -a) test }
//777 | echo -a return is: $777

...or like naming a scriptfile "4" and attempting to get $script(4), or adding "0" as highlight text and $highlight(0).sound, or several similar cases I did not think of.
Posted By: argv0 Re: $timer() with number as timer id - 18/02/10 05:45 PM
Although it would be better if there was some kind of switch in $timer() to denote that you were referring to a timer by name.

$timer(777,n) for instance
Posted By: Zed Re: $timer() with number as timer id - 19/02/10 05:27 PM
Originally Posted By: Horstl
It's thus no bug but rather by design. Simply dont use a N as the timer name if you're ever going to use that identifier smile

It's like naming an alias N and using it as a custom identifier:
...

No, it's like using /timer without any timer id, and letting mirc increment the counter. wink
But the generated timer id is not the same as the timer's position in the $timer() list. And the script called by the timer can't easily get information about its timer with the $timer() identifier (unless it loops through all names with $timer(i) to locate the timer's "N").
Posted By: argv0 Re: $timer() with number as timer id - 20/02/10 06:37 AM
Yes, well, as I said, it would be better if mIRC had a switch to make both cases possible, but..

The automatic timer naming functionality in mIRC is a convenience for the simple case (a one-off timer to message someone or something). You should not rely on this functionality for scripts, especially those that need to access $timer(NAME) --for this very reason.

Similarly, you should consider numeric timer names as "reserved" in mIRC for the above simple case "auto increment" timer names. As such, you should not try to name any timers in this "namespace", since it is reserved for said timers. Of course, this is not a rule, just something of a convention. The easy fix here is to just name your timer something that is not numeric, as was mentioned, and stay away from stepping on mIRC's toes.

Posted By: Zed Re: $timer() with number as timer id - 21/02/10 01:35 AM
Originally Posted By: argv0
Similarly, you should consider numeric timer names as "reserved" in mIRC for the above simple case "auto increment" timer names.


I don't use numbers as timer names. I left that for the automatic numbering. I have used 777 in my example to ensure that the timer will not be given a slot number equal to its id.
I use named timers (with ou without a $cid part) mostly for specific timers that need to be run only once.

The confusing part with $timer(N/name) is the difference of behavior compared to /timer[N/name].

/timer always handle the [] as a name, not as a slot number.

example:
/.timertest 1 1000 echo -gs timer test
/.timer 1 1000 echo -gs timer numbered

"test" is in slot #1
"1" is in slot #2

//echo -gs $timer(1)
outputs "test" (slot #1)

/timer1 -e
ouputs "timer numbered" (timer named "1" in slot #2)
Posted By: Wims Re: $timer() with number as timer id - 21/02/10 11:19 PM
The help file says /timer[N/name] because you can use a name or a number to identify a timer, /timer1 doesn't mean the first timer in mIRC's internal list ($timer(1)), it means the timer that has the number 1 as id.

Quote:
$timer(N/name)
Returns the timer id of the Nth timer in the timers list.
Here, the N is the number for the mIRC's internal list so yes, as said, it's impossible to directly access an information about a timer which has a number for id.
Posted By: 5618 Re: $timer() with number as timer id - 22/02/10 07:04 AM
Originally Posted By: Wims
...so yes, as said, it's impossible to directly access an information about a timer which has a number for id.

$timer(timer1) works fine. This is not the format returned by $ctimer though.
Posted By: argv0 Re: $timer() with number as timer id - 22/02/10 09:22 AM
The timer in the above examples is named "1", not "timer1". Accessing a timer named "1" with $timer(timer1) does not work.
Posted By: 5618 Re: $timer() with number as timer id - 22/02/10 09:50 AM
From experience I thought that prefixing a timer name with "timer" was the same as just using the name.
However, I just tested it by downloading a copy of mIRC and you are correct in saying this is not the case.

I agree that timer names should not be numeric in nature, but an n-paramter as was suggested would perhaps be more elegant solution.
© mIRC Discussion Forums