mIRC Home    About    Download    Register    News    Help

Print Thread
Pipes causing new command lines #5302 07/01/03 03:28 AM
Joined: Jan 2003
Posts: 11
E
Ecks Offline OP
Pikka bird
OP Offline
Pikka bird
E
Joined: Jan 2003
Posts: 11
I have a quick question that I've been unable to figure out by looking at the FAQ, help file, and searching the forums (post by post no less!). I have a simple linkbot script that I run between channels. Whenever anyone uses the pipe character, it tries to execute a new command instead of just displaying it in the channel. Any help is much appreciated. Here's the simple code that I run.
Code:
 on *:TEXT:*:#ase:{
  if ( $cid == 1 ) {
    /scid 3 /msg #ase [G] < $+ $nick $+ > $1-
  }
  elseif ( $cid == 3 ) {
    /scid 1 /msg #ase [Q] < $+ $nick $+ > $1-
  }
}
 


-Ecks

P.S. The multi-server capabilities in mIRC are amazing. That was the one thing that I thought was missing from it, and now it's damn near perfect.

Re: Pipes causing new command lines #5303 07/01/03 07:57 AM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
You might try using $!1- .. or perhaps $!replace($!1-,|,$!chr(124)) .. one of those might do the trick.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: Pipes causing new command lines #5304 07/01/03 09:27 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
If you are always going to have those two connections as CID's 1 & 3
Code:
on *:TEXT:*:#ase:{
  var %a = $($1-,1),%b = $gettok([G]: :[Q],$cid,58),%c = 4 - $cid
  scid %c if ($me ison #ase) msg #ase %b $+(<,$nick,>) % $+ a
}


Re: Pipes causing new command lines #5305 09/01/03 03:15 AM
Joined: Jan 2003
Posts: 11
E
Ecks Offline OP
Pikka bird
OP Offline
Pikka bird
E
Joined: Jan 2003
Posts: 11
Yes, the connections remain the same. I'm only designing this script for me (although maybe I'll rewrite it so anyone can use it later). Your code worked wonderfully Nimue: but I was wondering if you'd explain the $($1-,1) section to me. I don't understand what this does (and it's obviously how you solved my problem since the rest is virtually the same as my code). Also, why did you re-write everything? Are variables quicker than if statements? Thanks for your help, it's much appreciated.

-Ecks

Re: Pipes causing new command lines #5306 09/01/03 08:17 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Oops yes I am used to using it for myself and sometimes forget to NOT use it elsewhere. laugh
$($1-,1) is simply a "shortcut" to $eval($1-,1) smile

I used this way simply for economy of code, you could do the same with "if (this) / elseif (that)"

Re: Pipes causing new command lines #5307 10/01/03 02:49 AM
Joined: Jan 2003
Posts: 11
E
Ecks Offline OP
Pikka bird
OP Offline
Pikka bird
E
Joined: Jan 2003
Posts: 11
Thanks again. I like to know how stuff works just as much as knowing that it DOES work. It kind of confused me that your version works when if you replace the $1- in my code with the $eval($1-,1) in your code it doesn't work. Is it that when you place it into a variable, it doesn't try to evaluate it at all? That's the only thing I can think of. Kind of a hack, but I'm glad it works smile.

-Ecks

Re: Pipes causing new command lines #5308 10/01/03 03:30 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
This is because identifiers are evaluated for each command that processes them. So, once when you send them to a different CID (/scid N), and then again when a command (in this case "/msg") is used.
Setting it unevaluated to %var and then using "/scid N /command % $+ var" inserts an extra evaluation (the $+), which you obviously cant do with "$!1-" / "$ $+ 1-" or it will evaluate literally to "$1-"

Hope that helps. smile

Re: Pipes causing new command lines #5309 10/01/03 03:57 AM
Joined: Jan 2003
Posts: 11
E
Ecks Offline OP
Pikka bird
OP Offline
Pikka bird
E
Joined: Jan 2003
Posts: 11
Yes, indeed it does. Thanks for the thorough explanation.

-Ecks

Re: Pipes causing new command lines #5310 11/01/03 11:13 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
There is a much simpler solution to your problem than of trying to avoid evaluations. Just "switch" the script to the proper CID and then execute any commands you want.
Code:
on *:TEXT:*:#ase:{
  if $cid == 1 || $cid == 3 {
    scid $mid(301,$cid,1)
    msg #ase $+(<,$nick,>) $1-
  }
}


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