mIRC Homepage
Posted By: Mendigo /timer bug? - 10/04/04 06:12 AM
hi,

/time is evaluating text more than one time, is it normal or a bug? Eg:

if a script have:
on 1:OPEN:?:*:{ .timer 1 1 checkmsg $nick $1- }

and anybody use the command:
/raw privmsg NICK :$findfile($mircdir,mirc.ini,0,0,quit)

I get disconnected.. i've found this same problem with some scripts/addons.


Posted By: Collective Re: /timer bug? - 10/04/04 06:47 AM
It's always been like this, and it's very useful. It allows you to evaluate identifiers when the command is performed instead of when the timer is started.

Here is a simple workaround, it isn't perfect mind you (has trouble with identifiers inside identifiers).
Code:
on 1:OPEN:?:*:{
  var %text 
  .echo -q $regsub($1-,/\$(?=\S)/g,\$!,%text)
  .timer 1 1 checkmsg $nick %text
}

You could also use $replace($1-,$,$+($,!)), but that also has problems.

Edit:
Code:
on 1:OPEN:?:*:{ 
  var %i = 1
  while ( $eval($+(%,onopen.,%i),2) != $null ) {
    inc %i
  }
  set $+(%,onopen.,%i) $1-
  .timer 1 1 checkmsg $nick $+(%,onopen.,%i) $chr(124) unset $+(%,onopen.,%i)
}

That way seems to work perfectly provided the alias doesn't /halt.
Posted By: Soul_Eater Re: /timer bug? - 10/04/04 07:46 AM
Code:
 
//raw privmsg NICK $+(:,$findfile($mircdir,mirc.ini,0,0,quit))
 


there.
Posted By: Collective Re: /timer bug? - 10/04/04 07:50 AM
Why did you post that? It just disconnects whoever types it and doesn't solve the original problem.
Posted By: Epsilon Re: /timer bug? - 13/04/04 08:16 AM
Do not pay attention to Soul_Eater he never read the messages and was probably responding to a message thread from another forum smirk
Posted By: tontito Re: /timer bug? - 13/04/04 11:31 AM
on 1:OPEN:?:*:{ .timer 1 1 checkmsg $nick $($1-,0) }

works fine like this with no problems
Posted By: qwerty Re: /timer bug? - 13/04/04 12:04 PM
No, it doesn't. What your code does is make mirc evaluate $1- each time the /timer fires (and not in the script). But $1- "inside" a /timer is always $null.

Generally, you should test your code first. Posting an entirely wrong solution is often worse than not posting at all.
Posted By: tontito Re: /timer bug? - 13/04/04 12:17 PM
well your are right but $(,0) or $eval(,0) should force to don't eval the $1-

from mirc.hlp:
$eval(text,N)
Evaluates the contents of text N times. If N isn't specified, the default is N = 1. If N is zero, text is not evaluated.

this timer has a particular way to always eval stuff.
Maybe it is better to implement the timer so it, when using the $(,0) don't eval.
Posted By: tidy_trax Re: /timer bug? - 13/04/04 12:21 PM
$($1-,0) is still evaluated in a timer, it is just re-evaluated each time the timer is called, as is $!1-, and qwerty did test it, which is why he knew it didn't work wink

edit: i already suggested that here
Posted By: tontito Re: /timer bug? - 13/04/04 12:25 PM
yep noticed that now, the $(,0) only works in a timer for some situations
Posted By: qwerty Re: /timer bug? - 13/04/04 01:01 PM
I don't think you got it. $(,0) always works in /timer (or in any other command). What doesn't work is $1- "inside" a /timer. Type this, to see what I mean:

//tokenize 32 a b c d | .timerblah1 -m 1 10 echo 3 -s one $1- two | .timerblah2 -m 1 20 echo 4 -a three $($1-,0) four | timerblah*

The result is:
Code:
[color:blue]-
* Active timers:
* Timer blah1 1 time(s) 10ms delay echo 3 -s one a b c d two
* Timer blah2 1 time(s) 20ms delay echo 4 -a three $1- four
-[/color]
[color:green]one a b c d two[/color]
[color:red]three four[/color]
You can see that in blah1 timer, the contents of $1- in the current script are passed, whilst in blah2, the string "$1-" itself is passed. This means that $(,0) worked fine in blah2. The problem is that $1- inside a command performed by /timer is empty. That's because $1- either refers to the parameters of an alias or the text from an event. Inside a /timer though, there is neither an alias or an event involved, so $1- is $null.
© mIRC Discussion Forums