mIRC Home    About    Download    Register    News    Help

Print Thread
simple timer bug #71350 14/02/04 04:34 AM
Joined: Feb 2004
Posts: 13
M
medowl Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Feb 2004
Posts: 13
as far as i know this bug has been present in the last few versions of mirc i've been scripting in (5.x - 6.12), just never knew about this bug reporting forum smile and the work around is pretty simple...

bug :
timers can only take one command , and not several between {}

very simple test code :

ALIAS TimerTEST {
timerTEST 1 5 { echo -a test1 | echo -a test2 }
}

returns 'test2' immediately and 'test1' at the end of the timer



quick work around : create an alias for the commands :

ALIAS TimerTEST {
timerTEST 1 5 { echoTEST }
}

ALIAS echoTEST {
echo -a test1 | echo -a test2
}


Re: simple timer bug #71351 14/02/04 04:43 AM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
I don't see how this is a bug. There is no suggestion that this should work in the help file (or I can't find it).

//timerTEST 1 5 echo -a test1 $chr(124) echo -a test2 works fine.

Re: simple timer bug #71352 14/02/04 05:07 AM
Joined: Feb 2004
Posts: 13
M
medowl Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Feb 2004
Posts: 13
imo its most definitely a bug...

1st of all is highly inconsequent with the rest of the scripting language, were { command1 | command2 | command3 | etc...} is all all other situations is handled as one command...
eg : if (%temp == 1) { echo -a test1 | echo -a test2 }

2. its just weird that the timer executes the part after the | straight away , but executes the first part only when the timer has run out

3. the help file has this to say about the | character :
For multiple commands you should use a | character (the shifted character usually under the \ key).
which imo implies it should work about everywhere you wanna use several command on one line...



Re: simple timer bug #71353 14/02/04 05:14 AM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
1. Then we have a difference of opinion. /scon and /scid don't work like that, /window doesn't either. I know of nowhere where it works for commands, apart from if, elseif and else.

2. Not really. The | is the command seperator as you point out, it's just in this case it seperates the timer command from the second echo command (i.e. the command before the | and the command after it).

The reason the $chr(124) method works is that it is evaluated in the timer command, where as a plain | is never seen by the timer command.

3. See above. It's just not how it is parsed.


I will agree, though, that it would be nice if | worked for that kind of command, as long as the { } braces were used.

Re: simple timer bug #71354 14/02/04 05:27 AM
Joined: Feb 2004
Posts: 13
M
medowl Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Feb 2004
Posts: 13
Quote:
I will agree, though, that it would be nice if | worked for that kind of command, as long as the { } braces were used.


hehe yeah that might actually be the best way to approach this (imo) inconsequency...
would be nice tho if it was supported in a newer version tho, coz timers are just sweet things...

but thats just me smile , thnx for pointing out the the $chr(124) workaround tho

Re: simple timer bug #71355 14/02/04 12:25 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Quote:
ALIAS TimerTEST {
timerTEST 1 5 { echo -a test1 | echo -a test2 }
}


/timer can take multiple commands, it simply doesn't support the syntax you're using.

Code:
ALIAS TimerTEST {
timerTEST 1 5 echo -a test1 $chr(124) echo -a test2
}


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: simple timer bug #71356 15/02/04 12:12 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
hasarrived {
set -u120 %hasarrived. $+ $1 $+ .on. $+ $2 0
.timer.hasarrived. $+ $1 $+ .on. $+ $2 0 1 if ( $1 ison $2 ) $({,0) .timer.hasarrived. $+ $1 $+ .on. $+ $2 off $(|,0) msg $2 Finally $1 has arrived I have only been waiting $!duration( % $+ hasarrived. $+ $1 $+ .on. $+ $2 ) $(|,0) echo -s The watch for $1 arriving on $2 started at $date $time spotted em at $($date,0) $($time,0) after waiting for em for $!duration( % $+ hasarrived. $+ $1 $+ .on. $+ $2 ) $(|,0) unset % $+ hasarrived. $+ $1 $+ .on. $+ $2 $(},0) $(|,0) if ( $1 !ison $2 ) $({,0) set -u120 %hasarrived. $+ $1 $+ .on. $+ $2 1 + % $+ hasarrived. $+ $1 $+ .on. $+ $2 $(|,0) if ( % $+ hasarrived. $+ $1 $+ .on. $+ $2 >= 604800 ) $({,0) .timer.hasarrived. $+ $1 $+ .on. $+ $2 off $(|,0) msg $2 Wow I give up $1 hasnt been here for a week. $(|,0) unset % $+ hasarrived. $+ $1 $+ .on. $+ $2 $(},0) $(},0)
}

/hasarrived username #channelname

multiple command work ok in a timer, u just have to know how to incase them.
you have to remember that everything in the timer is going to have been evaluated once before the timer is created (as of course you would want them to be),

You well notice that i uses $({,0) $(|,0) $(},0) which of course gets evaluated to being { | } accordingly, and added to the line that the timer is, when the timer goes off it evaluates them for what they then are (as it should).
See that i also used a $($time,0) & $($date,0) as well as $time & $date becuase one needed to be evaluated at the start of the timer the other when it was dispayed.

The interpreter cant be expected to know what you wanted to do so has to be told, thats why the { | } all are evaluated at the creation time of the timer, the interpretor doesnt know you want them not evaluated.

Re: simple timer bug #71357 18/02/04 07:12 PM
Joined: Feb 2003
Posts: 810
C
cold Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Just a side note, you can use $(|) instead of $(|,0) (although you can't with { and }).
About $($time,0) and $($date,0), the same could be achieved with $!time and $!date.

Last edited by cold; 18/02/04 07:14 PM.

* cold edits his posts 24/7
Re: simple timer bug #71358 19/02/04 02:58 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I try to keep my code in symetry even if it means a bit more typing, its just prefrence, but here as with the use of $($time,0) etc i was trying to show a point about producing zero evaluations of a object, which was the basis of his problemwith the timer not doing as he expected.
While the other ways are less code, and i uses em regually i felt it might confusde the issue have $({,0) ${|) & $!time

As a side note, did you notice how i didnt uses a ELSE but rather useds a !negator of the original IF condition, when in a timer like this, for what ever reason the ELSE is not acted apon in a normal fashion. Its fine when like this
a = 1 , b = 1
if (a == b) { echo same } else { | echo different}
result "same"

but if its
a = 1 , b = 2
result "differnt"
ELSE Unknown command ( aka a raw 421)

its like the IF failes so the codes jumped over then it hits the ELSE and goes hmm dont know that command must be a server command ill send it off to the server, aghh more code follows echo "different". (maybe i missed something but couldnt find it when i looked)

I guess a dummy alias ELSE { } could be added, but i think thats a bit shonky as then if your calling an alais you might as well put all the code in one.

The reason i learnt to do timers with multiple commands, was so i could flush all the scripts files, and still have an event perform as i wished it to, no missing alias being called.


Re: simple timer bug #71359 19/02/04 03:14 AM
Joined: Feb 2004
Posts: 13
M
medowl Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Feb 2004
Posts: 13
nice piece of timer coding DaveC

but i would prefer using a seperate alias to be called from a timer incase i had so much commands..

i was merely trying to do 2 or 3 commands from a timer

Re: simple timer bug #71360 19/02/04 04:24 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
i use a complexe one like that to reload script files becuase when they unload the alias is gone so cant be called smile