mIRC Homepage
Posted By: Ecks Pipes causing new command lines - 07/01/03 03:28 AM
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.
Posted By: Hammer Re: Pipes causing new command lines - 07/01/03 07:57 AM
You might try using $!1- .. or perhaps $!replace($!1-,|,$!chr(124)) .. one of those might do the trick.
Posted By: Nimue Re: Pipes causing new command lines - 07/01/03 09:27 AM
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
}

Posted By: Ecks Re: Pipes causing new command lines - 09/01/03 03:15 AM
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
Posted By: Nimue Re: Pipes causing new command lines - 09/01/03 08:17 AM
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)"
Posted By: Ecks Re: Pipes causing new command lines - 10/01/03 02:49 AM
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
Posted By: Nimue Re: Pipes causing new command lines - 10/01/03 03:30 AM
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
Posted By: Ecks Re: Pipes causing new command lines - 10/01/03 03:57 AM
Yes, indeed it does. Thanks for the thorough explanation.

-Ecks
Posted By: qwerty Re: Pipes causing new command lines - 11/01/03 11:13 PM
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-
  }
}
© mIRC Discussion Forums