Originally Posted By: RusselB
I'm trying to write a code that will send a message to all of the channels that I & a named person share. I also want to be able to use multiple names, and send a different message based upon the name, with the previous message being used as a default.
Here's the code so far
Code:
alias cmsg {
  var %cmsg.nicks = $iif($gettok($1-,1,44),$v1,$$input(Space or Comma separated,e,Matching nicks))
  %cmsg.nicks = $replace(%cmsg.nicks,$chr(44),$chr(32))
  var %a = 1, %b = $numtok(%cmsg.nicks,32)
  while %a <= %b {
    var %cmsg.msg = $iif($gettok($1-,2,44),$gettok($1-,2,44),$$input(Common message,e,,$iif(%cmsg.msg,$v1)))
    var %cmsg.nick = $gettok(%cmsg.nicks,%a,32), %c = 1, %d = $comchan(%cmsg.nick,0)
    while %c <= %d {
      var %cmsg.chans = $addtok(%cmsg.chans,$comchan(%cmsg.nick,%c),44)
      inc %c
    }
    .msg %cmsg.chans %cmsg.msg
  }
  inc %a
}

It appears the problem is around line 6, as it keeps prompting me for a new message, no matter how many (or few) nicks were specified. At the moment, I'm testing the code without specifying the nicks or message in the /cmsg command line.

Originally Posted By: RusselB
Thanks for the information.

The reason I'm using $gettok($1-,1,44) is so that a person can use the alias in the format of
/cmsg <nick1> <nick2> <nick3> <nick4>,<message>


$replace(%cmsg.nicks,$chr(44),$chr(32)) is saying that you can use either a comma or space... The problem is with how you are parsing the command line parameters. Where do the nicks end and the message begin?

If you just allowed comma's you could simply use $gettok on $1 (instead of $1-) for the nicks


Originally Posted By: RusselB
Make your own topic, and stop posting on mine.


I was thinking the same thing reading this thread...