mIRC Home    About    Download    Register    News    Help

Print Thread
#78717 10/04/04 06:12 AM
Joined: Apr 2004
Posts: 1
M
Mendigo Offline OP
Mostly harmless
OP Offline
Mostly harmless
M
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.



#78718 10/04/04 06:47 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
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).
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.

#78719 10/04/04 07:46 AM
Joined: Mar 2003
Posts: 187
S
Vogon poet
Offline
Vogon poet
S
Joined: Mar 2003
Posts: 187
Code:
 
//raw privmsg NICK $+(:,$findfile($mircdir,mirc.ini,0,0,quit))
 


there.

#78720 10/04/04 07:50 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Why did you post that? It just disconnects whoever types it and doesn't solve the original problem.

#78721 13/04/04 08:16 AM
Joined: Oct 2003
Posts: 12
E
Pikka bird
Offline
Pikka bird
E
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 smirk


#78722 13/04/04 11:31 AM
Joined: Feb 2003
Posts: 307
T
Fjord artisan
Offline
Fjord artisan
T
Joined: Feb 2003
Posts: 307
on 1:OPEN:?:*:{ .timer 1 1 checkmsg $nick $($1-,0) }

works fine like this with no problems

#78723 13/04/04 12:04 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
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
#78724 13/04/04 12:17 PM
Joined: Feb 2003
Posts: 307
T
Fjord artisan
Offline
Fjord artisan
T
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.
#78725 13/04/04 12:21 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
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 wink

edit: i already suggested that here

Last edited by tidy_trax; 13/04/04 12:27 PM.

New username: hixxy
#78726 13/04/04 12:25 PM
Joined: Feb 2003
Posts: 307
T
Fjord artisan
Offline
Fjord artisan
T
Joined: Feb 2003
Posts: 307
yep noticed that now, the $(,0) only works in a timer for some situations

#78727 13/04/04 01:01 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
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:
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard