mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2017
Posts: 19
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Nov 2017
Posts: 19
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
}

Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
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()


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2017
Posts: 19
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Nov 2017
Posts: 19
Ahhh!!

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

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


Link Copied to Clipboard