mIRC Home    About    Download    Register    News    Help

Print Thread
#116787 08/04/05 11:29 PM
Joined: Mar 2005
Posts: 19
W
Wishie Offline OP
Pikka bird
OP Offline
Pikka bird
W
Joined: Mar 2005
Posts: 19
Sorry for the topic title, couldn't come up with a better one.

Anyways, I have a problem with a script, that I'm afraid I can't solve on my own.

It goes like this:
Code:
on *:text:$(*startlog*):? {
  if ( $nick == %rootn ) set %log 1 | set %lchan $2 | msg $nick Now logging %lchan | halt
  else if ( $nick == %rootn2 ) set %log 1 | set %lchan $2 | msg $nick Now logging %lchan | halt
  else msg $nick Access denied
}


My problem is on the third line, "else if ( $nick == %rootn2 ) set %log 1....". It won't execute the "set %log 1" command. However, in the line above it, it works without any problem at all.

Thanks for any replies.

Regards,
Wishie

Last edited by Wishie; 08/04/05 11:29 PM.
#116788 08/04/05 11:32 PM
Joined: Feb 2005
Posts: 24
R
Ameglian cow
Offline
Ameglian cow
R
Joined: Feb 2005
Posts: 24
on *:text:$(*startlog*):? {

if ( $nick == %rootn ) set %log 1 | set %lchan $2 | msg $nick Now logging %lchan | halt

elseif ( $nick == %rootn2 ) set %log 1 | set %lchan $2 | msg $nick Now logging %lchan | halt

else msg $nick Access denied

}

it's ELSEIF not ELSE IF laugh

#116789 08/04/05 11:38 PM
Joined: Mar 2005
Posts: 19
W
Wishie Offline OP
Pikka bird
OP Offline
Pikka bird
W
Joined: Mar 2005
Posts: 19
Huh? Is that new or something? confused It says "else if" in my tutorial. frown

Dammit, it works. Thanks Ratzor! laugh Appreciated.

#116790 09/04/05 01:19 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
else if works as well.
The problem is more likely that he's not using { }

Edit:

Here's an example, i'm sure you'll notice the difference:

Code:
alias test {
  if (0) echo -a 1 | echo -a 2 | echo -a 3
}
alias test2 {
  if (0) { echo -a 1 | echo -a 2 | echo -a 3 }
}


//test | test2


New username: hixxy
#116791 09/04/05 01:23 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
It shouldn't work because you're missing a : after the ? in the event declaration.


New username: hixxy
#116792 09/04/05 10:20 AM
Joined: Mar 2005
Posts: 19
W
Wishie Offline OP
Pikka bird
OP Offline
Pikka bird
W
Joined: Mar 2005
Posts: 19
I have discovered that I don't need the last colon at all when scripting remotes. They work just as fine without them. :tongue:

#116793 10/04/05 12:21 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Just a couple of ideas I thought to add to the discussion.

Code:
on $*:TEXT:/^startlog (#\S+)$/iS:?:{
  if (!$istok(%rootn %rootn2,$nick, 32)) { 
    .notice $nick Permission denied.
  }
  else {
    set %log 1
    set %lchan $regml(1)
    .notice $nick Now logging %lchan
  }
}


Or:

//auser rootn %rootn | auser rootn %rootn2
Code:
on $rootn:TEXT:/^startlog (#\S+)$/iS:?:{
  set %log 1
  set %lchan $regml(1)
  .notice $nick Now logging %lchan
}
on $*:TEXT:/^startlog (#\S+)$/iS:?: .notice $nick Permission denied.


While the final colon is not required, getting into the practice of omitting it will eventually cause you problems you won't be able to track down. And THAT is a true statement, just as omitting the = after /var will eventually bite you as well and be very hard to troubleshoot. Get into the habit of following standard coding practices in whatever environment you find yourself and you'll save much time down the road in troubleshooting to make it well worth your time investment.

You alter from the standard only when you have a specific reason to do so, not just because you can get away with it (for now). For instance, while using command separators (|) and writing all your commands on a single line is faster to process, it is also harder to read and therefore troubleshoot, especially when there are multiply nested code blocks. In this instance, you have to ask yourself if speed is really an issue or not: Will this code be executed so often that the decrease in maintainability be worth the small speed increase gained? Most often, it won't be worth it; sometimes, it is very necessary. So, unless you have a specific reason for varying from the standard, write your code (basically) the same way everyone else does. This also makes it easier for others to give you assistance when you need help.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#116794 10/04/05 12:06 PM
Joined: Mar 2005
Posts: 19
W
Wishie Offline OP
Pikka bird
OP Offline
Pikka bird
W
Joined: Mar 2005
Posts: 19
Yeah I suppose you are right, that I should follow the standards. I'll start doing so. smile

Oh and, I don't understand a lot of the code you posted. blush


Link Copied to Clipboard