mIRC Home    About    Download    Register    News    Help

Print Thread
#81902 04/05/04 08:09 PM
Joined: Apr 2004
Posts: 21
_
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Apr 2004
Posts: 21
hi,

i created a var in the variables section "%test 1"

then i made an alias:

Code:
 alias test {
  timertest 0 1 if (%test == 1) { timertest off | echo -a yes } 
}


if i type in "/test" it shows ALWAYS "yes" and the timer halts,doesnt matter if "%test" is 1 or not.

if i type exactly this in the console:

"/timertest 0 1 if (%test == 1) { timertest off | echo -a yes } "

it works fine and shows nothing and the timer runs when its not 1...

why is that?!

Last edited by _Delphi_; 04/05/04 08:19 PM.
#81903 04/05/04 08:27 PM
Joined: Dec 2002
Posts: 208
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
You can't exactly do it that way from within script. Since | seperates commands, it doesn't put both of those on the timer, so the /echo is done right away when you run the alias and only the "if (%test == 1)" and "timertest off" are executed on the timer. What you need to do to get this to work is to use $chr(124) instead of the | as follows:

alias test {
timertest 0 1 if (%test == 1) { timertest off $chr(124) echo -a yes }
}


If I knew now what I will know then... maybe things will have been different...
#81904 05/05/04 12:48 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Not even this will work. During the evaluation of the parameters passed to timer (inside the routine that called it), { and } are lost. You can see what I mean with this:

alias test {
.timertest 0 1 if (%test == 1) { timertest off $chr(124) echo -a yes }
timertest
}

Since { and } are lost, mirc thinks that "echo -a yes" is not part of the /if statement.

One would have to use $({,) or $chr(123) instead of { and $(},) or $chr(125) instead of }.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#81905 05/05/04 06:05 PM
Joined: Apr 2004
Posts: 21
_
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Apr 2004
Posts: 21
thanks for answers.

What can i do now instead of using aliases ?

if i use aliases and the aliases has also timers etc, i will have spghetti-code at end. isnt there a way? like

.timer 0 1 {
if (%bla == 1) { blub }
}

this?


Link Copied to Clipboard