|
Joined: Apr 2004
Posts: 1
Mostly harmless
|
OP
Mostly harmless
Joined: Apr 2004
Posts: 1 |
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.
|
|
|
|
Joined: Dec 2002
Posts: 3,138
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,138 |
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). 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: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.
|
|
|
|
Joined: Mar 2003
Posts: 187
Vogon poet
|
Vogon poet
Joined: Mar 2003
Posts: 187 |
//raw privmsg NICK $+(:,$findfile($mircdir,mirc.ini,0,0,quit))
there.
|
|
|
|
Joined: Dec 2002
Posts: 3,138
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,138 |
Why did you post that? It just disconnects whoever types it and doesn't solve the original problem.
|
|
|
|
Joined: Oct 2003
Posts: 12
Pikka bird
|
Pikka bird
Joined: Oct 2003
Posts: 12 |
Do not pay attention to Soul_Eater he never read the messages and was probably responding to a message thread from another forum
|
|
|
|
Joined: Feb 2003
Posts: 307
Fjord artisan
|
Fjord artisan
Joined: Feb 2003
Posts: 307 |
on 1:OPEN:?:*:{ .timer 1 1 checkmsg $nick $($1-,0) }
works fine like this with no problems
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
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.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Feb 2003
Posts: 307
Fjord artisan
|
Fjord artisan
Joined: Feb 2003
Posts: 307 |
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.
Last edited by tontito; 13/04/04 12:24 PM.
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
$($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 edit: i already suggested that here
Last edited by tidy_trax; 13/04/04 12:27 PM.
New username: hixxy
|
|
|
|
Joined: Feb 2003
Posts: 307
Fjord artisan
|
Fjord artisan
Joined: Feb 2003
Posts: 307 |
yep noticed that now, the $(,0) only works in a timer for some situations
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
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: [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.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
|