mIRC Home    About    Download    Register    News    Help

Print Thread
$regex call causes an error - unknown command #261744 22/11/17 09:14 AM
Joined: Nov 2017
Posts: 13
G
goblin58 Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Nov 2017
Posts: 13
I'm not %100 sure that this is an issue or not, however if you do not use the return value of a $regex call an 'Unknown command' error is invoked. The error can be reproduced with the following code snippet.

Code:
alias test {

  %data = 2d

  ; validate that the data is correct an usable

  if ($regex(%data, /^[1-9][smhd]|[1-9][0-9]+[smhd]$/)) {

    ; this line produces an error 
    ; Error: <nick> 1 Unknown command
    ; the '1' appears to be the number of groups encountered

    $regex(%data, /(\D)/g))

    ; using the result of the $regex does not invoke an error

    if ($regex(%data, /(\D)/g)) {
      echo -a $regml(1)
    }

    ; you may consider not testing the result of the $regex as  
    ; bad coding practise however the data has been previously 
    ; tested as being valid

  }
}

raw 421:*: {
  echo 4 -a Error: $1 $2 $3 $4 $5 $6 $7 $8 $9
  halt
}

Re: $regex call causes an error - unknown command [Re: goblin58] #261746 22/11/17 09:32 AM
Joined: Jul 2006
Posts: 3,530
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,530
You're executing the returning value of $regex as a command, this is all normal.
If you do not want to execute the value returned by identifiers as command, but you want to discard that value, use /noop $ident()


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $regex call causes an error - unknown command [Re: Wims] #261748 22/11/17 10:09 AM
Joined: Nov 2017
Posts: 13
G
goblin58 Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Nov 2017
Posts: 13
Ahhh!!

I wasn't aware of the /noop command. Thanks for that!

That raises new possibilities, dynamic commands, like function pointers smile