mIRC Home    About    Download    Register    News    Help

Print Thread
//timer eating ) brackets in if statement #92574 03/08/04 08:34 AM
Joined: Aug 2004
Posts: 3
T
TheBlackPanther Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Aug 2004
Posts: 3
Using version 6.03 here, but i had someone test with 6.16 and got the same results.... the problem is as follows:

This works as it should:
/timer 1 1 //if ($me isop $chan(1)) echo -a hi

This does not:
//timer 1 1 if ($me isop $chan(1)) echo -a hi

if you check the /timers after starting the second timer, it appears like this:
* Timer 1 1 time(s) 1s delay if ($me isop #chan echo -a hi (Network)

Notice no ) after #chan
This means you can't use an if statement in a timer if it's called from an alias or remote. When the timer goes off it returns:
* /if: invalid format

Adding more )'s does not change anything in the display of /timers
For Example:

//timer 1 1 if ($me isop $chan(1)) echo -a hi

IS THE SAME AS

//timer 1 1 if ($me isop $chan(1))))))))) echo -a hi


Now, I know workarounds for the problem, (make an alias to evaluate the if, put a space after #chan before the bracket, etc, etc) but I thought the bug should be reported anyway, and hopefully it can be fixed. smile

Re: //timer eating ) brackets in if statement #92575 03/08/04 08:57 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Yeah the "$chan(1))" part gets evaluated when you set the timer, but the "($me" doesn't because of the "(". To avoid it, use $!chan(1)) to delay evaluation until the timer executes so both parts of the if statement can be evaluated together.

Re: //timer eating ) brackets in if statement #92576 03/08/04 09:01 AM
Joined: Dec 2002
Posts: 266
Z
zack Offline
Fjord artisan
Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Yes, but the evaulation shouldn't remove the last parenthesis.


You won't like it when I get angry.
Re: //timer eating ) brackets in if statement #92577 03/08/04 09:02 AM
Joined: Aug 2004
Posts: 3
T
TheBlackPanther Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Aug 2004
Posts: 3
Right... That would work for a line as simple as this, but the actual script i'm trying to create is a lot more complicated, the $chan(1) needs to be evaluated when the timer is set, not when it executes since it's set up in a loop and there are multiple timers and multiple channelnames

Re: //timer eating ) brackets in if statement #92578 03/08/04 09:13 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
It always does when evaluating $identifiers with parameters . smile

//echo -a $chan(1))
^^ will not have a parenthesis added to the channel name.

//echo -a $scon(1))
^^ Won't be 1)

Re: //timer eating ) brackets in if statement #92579 03/08/04 09:15 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
mm well, you can also use this format

//timer 1 1 if $me isop $chan(1) { echo -a hi }
//timer 1 1 if $!server && $me isop $chan(1) $({,) echo -a hi $(},)

Re: //timer eating ) brackets in if statement #92580 03/08/04 11:42 AM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
If your script is a lot more complicated make an alias and use the timer to call the alias. Much easier.

(Addition to original report) #92581 04/08/04 06:14 AM
Joined: Aug 2004
Posts: 3
T
TheBlackPanther Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Aug 2004
Posts: 3
Actually, the $me should have been evaluated when the timer was set as well, instead it showed as ($me


Please Note: I won't be responding to anyone offering work arounds. I know how to make mIRC do what I want. The simple fact is, it's not functioning the way it seems it should.

Re: (Addition to original report) #92582 04/08/04 10:55 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
The reason $me isn't evaluated is because there's a parenthesis '(' in front the the dollar sign. mIRC only evaluates things when the first character is either '%' or '$'. The simple solution to the problem, and it's not a problem that mIRC can really fix - just an unfortunate consequence of unquoted strings, is to put a space between the parentheses and the operands.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: //timer eating ) brackets in if statement #92583 07/08/04 11:16 PM
Joined: Dec 2002
Posts: 12
T
TimeFX Offline
Pikka bird
Offline
Pikka bird
T
Joined: Dec 2002
Posts: 12
/timer 1 1 if ( $+ $me isop $chan(1) $+ ) echo -a hi

Re: //timer eating ) brackets in if statement #92584 14/08/04 07:12 PM
Joined: Feb 2003
Posts: 810
C
cold Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
$+ aren't needed, / isn't used (it's // that's used), therefore, $me and $chan(1) shouldn't be evaluated.
As it was suggested before, use //timer 1 1 if ($me isop $!chan(1)) echo -a hi

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

* cold edits his posts 24/7