mIRC Home    About    Download    Register    News    Help

Print Thread
return x amount of results #139559 16/01/06 04:29 PM
Joined: Aug 2005
Posts: 25
E
enotsoc Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Aug 2005
Posts: 25
how can i modify this code to return a certain amount of results. lets say i want it to return 5 or 10 instead of only 1 result that it gives when the trigger is used

on *:TEXT:!url *:#:bb_url_trigger $1-
on *:INPUT:*: { if ( $1 == !url ) { bb_url_trigger $1- | halt } }

alias bb_url_trigger {
var %input $replace($2-,$chr(36), $+ $chr(36) $+ ,$chr(37), $+ $chr(37) $+ ,$chr(62),.,$chr(124),.)
if ( !%input ) || ( $2 == help ) {
$iif($nick == $me,echo -ta,.notice $nick) URL-SEARCH
$iif($nick == $me,echo -ta,.notice $nick) Usage: !url searchstring (wildcards possible)
$iif($nick == $me,echo -ta,.notice $nick) Example: "!url german.imdb" or "!url BrotBueXe" or "!url that*the"
$iif($nick == $me,echo -ta,.notice $nick) Hint: You can only get urls that are catched anytime in this chan. You can search for nicks or msgs also.
halt
}

var %line = $read(" $+ $scriptdir $+ bb-urlcatcher.hist $+ ",w,$+(*,$chr(9),$iif($nick == $me,*,$chan),$chr(9),*,%input,*))

if ( %line == $null ) $iif($nick == $me,echo -ta ,.notice $nick) nothing found smirk
else {
;$iif($nick == $me,echo -ta,msg $iif($chan != null,$ifmatch,%nick)) [URLHIST] $gettok(%line,1,9) / $gettok(%line,3,9) $+ : $gettok(%line,4,9)
$iif($nick == $me,echo -ta,.notice $nick) Entrys: $lines(" $+ $scriptdir $+ bb-urlcatcher.hist $+ ") - New: %bb-url-catcher-new - Overall: %bb-url-catcher-count
$iif($nick == $me,echo -ta,.notice $nick) $gettok(%line,5,9) posted on $chr60 $gettok(%line,1,9) $+ $chr60 by $chr60 $+ $chr60 $gettok(%line,3,9)
}

the 1 return with the search doesnt help much, so 5 or 10 would be a bit more helpful to help people find the url they want

Re: return x amount of results #139560 16/01/06 09:36 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
on *:TEXT:!url *:#:bb_url_trigger $1-
on *:INPUT:*: { if ( $1 == !url ) { bb_url_trigger $1- | halt } }

alias bb_url_trigger {
  var %input $replace($2-,$chr(36), $+ $chr(36) $+ ,$chr(37), $+ $chr(37) $+ ,$chr(62),.,$chr(124),.)
  if ( !%input ) || ( $2 == help ) {
    $iif($nick == $me,echo -ta,.notice $nick) URL-SEARCH
    $iif($nick == $me,echo -ta,.notice $nick) Usage: !url searchstring (wildcards possible)
    $iif($nick == $me,echo -ta,.notice $nick) Example: "!url german.imdb" or "!url BrotBueXe" or "!url that*the"
    $iif($nick == $me,echo -ta,.notice $nick) Hint: You can only get urls that are catched anytime in this chan. You can search for nicks or msgs also.
    halt
  }
  var %n = 1, %i = 1, %m = 10
  while (%i <= %m) {
    var %line = $read(" $+ $scriptdir $+ bb-urlcatcher.hist $+ ",w,$+(*,$chr(9),$iif($nick == $me,*,$chan),$chr(9),*,%input,*),%n) | var %n = $readn | inc %n
    if ( %line == $null ) {
      if (%i == 1) { $iif($nick == $me,echo -ta ,.notice $nick) nothing found :/ }
      var %i = %m
    }
    else {
      ;$iif($nick == $me,echo -ta,msg $iif($chan != null,$ifmatch,%nick)) [URLHIST] $gettok(%line,1,9) / $gettok(%line,3,9) $+ : $gettok(%line,4,9)
      $iif($nick == $me,echo -ta,.notice $nick) Entrys: $lines(" $+ $scriptdir $+ bb-urlcatcher.hist $+ ") - New: %bb-url-catcher-new - Overall: %bb-url-catcher-count
      $iif($nick == $me,echo -ta,.notice $nick) $gettok(%line,5,9)  posted on $chr60 $gettok(%line,1,9) $+ $chr60 by $chr60 $+ $chr60 $gettok(%line,3,9)
    }
    inc %i
  }
}

* code untested * No flood control present use MIRC flood control *

I simply added a line to start searching from counter %n and a loop counter %i, and a max loop counter %m (10), each time it does a search, it updates the %n value to the located line $readn + 1, so the next search well be from the line after that, then if the line is empty and were still on the first of the it says nothing found, and either way if line is empty sets %i to %m (last loop), the rest is all yourt code using %line, up till the end where i added a INC %i, and loop back in the WHILE loop, you might want to add into your code the use of %i to say RESULT # $+ %i IS or some such blah....

This should give you between 0 - nothing found and 10 results

Re: return x amount of results #139561 16/01/06 11:29 PM
Joined: Aug 2005
Posts: 25
E
enotsoc Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Aug 2005
Posts: 25
ok i just tested and for some reason the code will then freeze mirc up.