mIRC Home    About    Download    Register    News    Help

Print Thread
Wildcards with on TEXT #265221 19/03/19 07:59 PM
Joined: Sep 2015
Posts: 26
Z
zigress Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Sep 2015
Posts: 26
Example Code:
Code:
ON *:TEXT:!test*:#: {
  if ($3) && ($3 !isnum) { echo 3 is not num | return }
  if ($2 == $null) { echo use !test [word] [number] | return }
  else { echo good }
}

If I want $1 (the command, !test) to be exact match but not $2 and $3, what wildcard (e.g. * or &, etc) should I use with this command? In its current form, I can use the following line to cause the command to run, which is not what I want:
!testhello hello 2

Thank you in advance!

Re: Wildcards with on TEXT [Re: zigress] #265222 19/03/19 08:18 PM
Joined: Jul 2006
Posts: 3,532
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,532
Wildcards cannot express condition, you cannot tell it that the first word should be !test and that the second word is optional without accepting a match such as "!test ", with only a space after it

* meaning anything, !test* does match !testhello, you want at least !test * but as said, it matches on "!test " which can be problematic.
You can use a general * for the matchtext and then check that $1 == !test, but that means the on text event triggers for any text spoken before deciding to do nothing on irrelevant text, meaning more processing, so using !test * is still the best idea, to avoid matching on any messages, and then you check for $2 and $3

Code:
on *:text:!test *:#:{
  if ($2 == $null) {
    echo use !test [word] [number]
    ;return is not really required in this simple example.
    ;return
  }
  elseif ($3 != $null) && ($3 !isnum) {
    echo $!3 is not num
  }
  else { 
    echo good
  }
}


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Wildcards with on TEXT [Re: Wims] #265226 19/03/19 10:56 PM
Joined: Sep 2015
Posts: 26
Z
zigress Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Sep 2015
Posts: 26
Ah, I understand. I'll just go ahead and use test * then. Thank you for your explanation!