mIRC Home    About    Download    Register    News    Help

Print Thread
#270982 05/11/22 03:06 AM
Joined: Dec 2021
Posts: 2
M
maxime Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Dec 2021
Posts: 2
Mirc version : 7.71

I'm in the process of learning the scripting language of mIRC.
I'm trying to avoid having debugging info (or script failure, or errors) popping up in the user window if he/she cancels an input instead of filling it.

[b][/b]Problem

I get this in the user window :

Code

IF($1 Unknown command
-
ELSE Unknown command
-
* No such identifier: $null) (line 5, remote.ini)

The code

Code

// https://en.wikibooks.org/wiki/MIRC_Scripting/Basics/Basics#Aliases
// Written in remote.ini 

alias F2 {
  var %n = $?="What's your nickname and password?"

  if(%n == $null) { 
     echo "nick change canceled." 
    } else {
      tokenize 32 %n
      nick $1
      quote nickserv identify $2
  }
}


Let me know if you need more information, any help is greatly appreciated, cheers.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I've never heard of the site you linked, and from the display containing dates as old as 2005/2008, it looks like this site is fairly old. It's possible that it's being kept up-to-date, but maybe not.

Have a look also at https://en.wikichip.org/wiki/mirc/introduction
and there's a #mirc or #mircscripting channel at most of the larger networks, some more active than others

Your example is not faithfully following the examples at the page you linked. While there are often several valid ways to do the same thing, you avoided them all, lol.

You should not follow the end-curly-brace with anything except a command separator.
"IF" is a command not an identifier. While it's common for identifiers to have the parenthesis touching themselves, you cannot do that with any command or alias name, so by having the parenthesis touching the 'if' this confuses the scripting engine. Try like:

Code
alias F2 {
  var %n = $input(What's your nickname and password?,e)

  if (%n == $null) { 
     echo "nick change canceled." 
    }
 else {
      tokenize 32 %n
      nick $1
      quote nickserv identify $2
  }
}

Another way you can do things is to take advantage of the behavior that anytime you have an identifier that uses $$ instead of $, if the return value is blank, it halts the script. so if this used $$Input instead of $input, you wouldn't need to handle the case where it returned $null

Joined: Dec 2021
Posts: 2
M
maxime Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Dec 2021
Posts: 2
Quote
I've never heard of the site you linked, and from the display containing dates as old as 2005/2008, it looks like this site is fairly old. It's possible that it's being kept up-to-date, but maybe not.


Thanks for checking it out.

I've taken your advice and ended up with this :

Code
alias F2 {
  var %n = $$input(What's your nickname and password?,e) 
  tokenize 32 %n
  nick $1
  quote nickserv identify $2
}

Which works wonderfully, avoiding the user cancellation handling feels more elegant. However, I'm afraid I have now more questions than when I originally posted my problem, lol.

Thanks again for the quick and efficient reply.

Cheers,

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I had been looking at the syntax, but not at what you're doing. This may fail if you're not already at that nick, if nickserv sees your password before the change nick happens. if that's a problem, you may need to introduce a delay after the /nick, using a timer and $unsafe. However, there's a good chance that newer nickserv lets you identify from any nick like "/nickserv identify accountname password", and nickserv uses your active nick only if you give it 3 words.
This variant halts the script if there's not a $2 word. If you want the nickchange to happen without a password, you can swap the last 2 commands

Code
alias F2 {
  if ($scid($cid).status != connected) { echo -ag you are not connected | return }
  tokenize 32 $$input(What's your nickname and password?,etd) 
  quote nickserv identify $1 $$2
  nick $1
}


Link Copied to Clipboard