mIRC Home    About    Download    Register    News    Help

Print Thread
#262488 07/02/18 12:00 AM
Joined: Dec 2017
Posts: 9
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2017
Posts: 9
the script below reads a mid, which is an id to a link, example if i type [mid]1234567[/mid] it will provide a link. but if type [mid]1234567[/mid] and [mid]2345678[/mid] it will only display the first link and not the second one.
Code:
on *:TEXT:*[mid]*[/mid]*:#: { 
  var %string = $remove($1-, $chr(32))
  var %codeStart = $pos(%string, [mid]) + 5
  var %codeLen = $pos(%string, [/mid]) - %codeStart
  var %code = $mid(%string, %codeStart, %codeLen)
  if ((%code isnum) && (%codeLen > 0)) {
    msg $chan https://www.pokemonlegends.com/monster?mid= $+ %code
  }
}
what am i doing wrong?

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Your logic above is only finding/extracting the first instance of [mid][/mid]. You would need to loop over the input text for each occurrence, grab the number and create the link.

With the power of regular-expressions as the match-text, you can have mIRC extract the occurrences for you:

Code:
; Triggers if one or more occurrences of [mid]_number_[/mid] occur in the input
; and stores the 'captured' number of each occurrence in $regml()
on $*:TEXT:/\[mid\](\d+)\s*\[\/mid\]\s*/giS:#:{
  var %idx = 0
  var %end = $regml(0)
  var %links

  ; loop over each captured number
  while (%idx < %end) {
    inc %idx

    ; Append the link of the captured number to the list of links
    %links = %links https://www.pokemonlegends.com/monster?mid= $+ $regml(%idx)
  }

  ; Msg the channel with the list of links
  msg # %links
}

Last edited by FroggieDaFrog; 07/02/18 01:10 AM.

I am SReject
My Stuff

Link Copied to Clipboard