mIRC Homepage
Posted By: thamirios need dynamic /timer name example - 06/03/22 02:23 PM
Hello community, I'm looking for an example for the dynamic assignment of timer names, if this is supported at all.
I've tried the following ways but so far I'm not getting the results I'm hoping for.

Code
/timer$nick 4 2 /doWhatever
; the timer should have the content of $nick as name
; but results in a timer named "$nick"

var %nickvar = $nick
/timer%nickvar 4 2 /doWhatever
; the timer should have the content of %nickvar as name
; but results in a timer named "%nickvar"

/timer $+ $nick 4 2 /doWhatever
; the timer should have the content of $nick as name
; but results in a timer named "1"


I've also tried the -N switch, but the result is the same.
Am I using the syntax incorrectly or does /timer not have the function I'm hoping for?
Is there another way to assign a timer to a $nick without a translation table (timer1 = %nick1, timer2 = %nick2, ...)?
I guess I just don't see the easy way. wink
Posted By: maroon Re: need dynamic /timer name example - 06/03/22 09:52 PM
Your 3rd example does what you want, assuming you're doing it in an event where $nick is defined.

If you're doing this in the editbox it fails because you're using only a single slash so identifier wouldn't evaluate, and because $nick isn't defined there either.

If you're doing this inside a script and getting timer1 from it, that's because $nick is not defined, so you're doing the same as timer $+ $null
Posted By: thamirios Re: need dynamic /timer name example - 07/03/22 07:09 PM
Thank you for your prompt reply.
I triggered it like this because I find this possibility easy to test.

Code
menu channel {
  timertest2:/timer $+ $nick 4 2 /echo $chan $nick
}


and the result looks like this.

Quote

* Timer 1 activated
* /echo: insufficient parameters
* /echo: insufficient parameters
* /echo: insufficient parameters
* /echo: insufficient parameters
* Timer 1 halted


so it's true that $nick is undefined.
I tried it now with the on:join event.

Code
on *:join:*:{
  timer $+ $nick 4 2 /echo $chan $nick
}


Quote

*** user1 has joined #Lobby
* Timer user1 activated
user1
user1
user1
user1
* Timer user1 halted


it works fine here. a useful information that $nick is not filled by menu.
I can live with that, I only need the function in the on:join and on:part events.
many thanks for the help. smile
Posted By: Wims Re: need dynamic /timer name example - 07/03/22 08:18 PM
The selected nickname(s) inside a nicklist can be access with $1 $2 etc.
© mIRC Discussion Forums