home *** CD-ROM | disk | FTP | other *** search
/ Dream 46 / Amiga_Dream_46.iso / Amiga / Internet / Irc / ChatBox1_164.lha / Rexx / aminetfind.cb < prev    next >
Text File  |  1997-10-24  |  5KB  |  146 lines

  1. /*) FASTAminetFind v2.2 by Josef Faulkner (panther@gate.net) IRC: Josef
  2. \\\ Written for Grapevine 2.0 beta
  3. ///
  4. \\\ Modified for ChatBox by Sami Itkonen <Sami.Itkonen@hut.fi>
  5. ///
  6. \\\ Usage:
  7. /// /alias find rx aminetfind.gvrexx
  8. \\\ /find [EXACT] <"substring"|"sub strings"> [output] [-w<width>] [-m<items>]
  9. ///
  10. \\\ Output is the command that will be launched with the results as the argument
  11. ///
  12. \\\ Examples:
  13. /// /find shapeshift echo
  14. \\\ ½Echo╗á| ssfaq09.lha        docs/help   48K   3 ShapeShifter FAQ 0.9 (preliminary)
  15. /// ½Echo╗ | MacRomTest.lha     misc/emu     1K   9 Shows version & verifies ShapeShifte
  16. \\\ ...
  17. /// Other examples:
  18. \\\ /find shapeshift msg josef    - sends output in a message to josef
  19. /// /find shapeshift say          - sends output to the channel
  20. \\\ /find shapeshift me           - if your nick is Aminet, this might be good :)
  21. /// /find "irc client"            - Searches for anything with "irc" AND "client"
  22. \\\ /find "irc client" say        - and sends it to the channel
  23. /// /find exact "irc client"      - Searches for anything with "irc client" exactly
  24. \\\ /find exact "irc client" say  - and sends it to the channel
  25. /// /find grapevine say -m1       - Shows only one line of output
  26. \\\ /find grapevine say -m5       - Shows 5 lines of output
  27. /// /find grapevine say -w120     - Truncates output to 120 characters
  28. \\\ /find grapevine say -w60 -m10 - Shows up to 10 lines truncating to 60 width
  29. /// /find "comm/net irc grape"    - Will search for comm/net (the directory)
  30. \\\ /find exact "
  31. ///
  32. \\\ Set maxsend to the maximum number of lines to send (does not affect echo)
  33. ///
  34. \\\ New Stuff:
  35. /// 1.1:
  36. \\\ o  Now searches for multiple keywords...
  37. /// 1.2:
  38. \\\ o  Now searches for two or more words exactly.  Use " quotes around the
  39. ///    search string to do this.
  40. \\\ 2.0:
  41. /// o  Now you can set the maximum number of items (-m<num>)
  42. \\\ o  Now you can set the maximum length of hte line (-w<num>)
  43. /// 2.1:
  44. \\\ o  bugfixes
  45. /// 2.2:
  46. \\\ o  Now reports errors more exactly (none found, maximum matches)
  47. /// Notes:
  48. \\\ o  If you search for more than one keyword you MUST put it in quotes.
  49. /// o  Quotes must be " quotes, not ' quotes.
  50. \\\ o  - options MUST be the last options on the line.
  51. (*/
  52.  
  53. addr=address()
  54. address value addr
  55.  
  56. if ~show('L','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then do
  57.         CMD '/echo You need rexxsupport.library version 30 or greater in libs:'
  58.         exit 10
  59. end
  60.  
  61. maxchansend=5
  62. maxechosend=20
  63. width=80
  64.  
  65. bold=d2c(2)
  66.  
  67. parse arg cmds
  68. do while left(word(cmds,words(cmds)),1)='-'
  69.         lw=upper(word(cmds,words(cmds)))
  70.         lc=left(lw,2)
  71.         num=right(lw,length(lw)-2)
  72.         if lc='-M' then do
  73.                 maxchansend=num
  74.                 maxechosend=num
  75.         end
  76.         if lc='-W' then do
  77.                 width=num
  78.         end
  79.         cmds=reverse(cmds)
  80.         parse var cmds .' 'cmds
  81.         cmds=reverse(cmds)
  82. end
  83. if upper(word(cmds,1))='EXACT' then do
  84.         exact=1
  85.         parse var cmds .' 'cmds
  86. end
  87. else exact=0
  88. if index(cmds,'"')>0 then do
  89.         parse var cmds '"'name'"' cmd
  90. end
  91. else do
  92.         parse var cmds name' 'comd
  93. end
  94. if exact then name='"'name'"'
  95. if ~showlist(H,'TCP') then address command 'mount TCP: from amitcp:devs/inet-mountlist'
  96. if ~showlist(H,'TCP') then address command 'mount TCP:'
  97. if showlist(H,'TCP') then do
  98.         if comd='' then comd='echo'
  99.         name=strip(name)
  100.         otext='Finding: '
  101.         if exact then otext=otext||'(exact) '
  102.         otext=otext||bold||name||bold
  103.         comd=strip(comd)
  104.         if comd~='' then otext=otext||', output command 'bold||comd||bold
  105.         otext=otext||', width 'bold||width||bold
  106.         if upper(comd)~='ECHO' then do
  107.                 length=maxchansend
  108.                 otext=otext||', maxlength 'bold||maxchansend||bold
  109.         end
  110.         else do
  111.                 length=maxechosend
  112.                 otext=otext||', maxlength 'bold||maxechosend||bold
  113.         end
  114.         otext=otext||'.'
  115.         'echo 'otext
  116.         call open(2,'t:a',w)
  117.         if open(1,'tcp:ftp.wustl.edu/1848',w) then do
  118.                 call writeln(1,'max 'length)
  119.                 call writeln(1,'width 'width)
  120.                 call writeln(1,'find 'name)
  121.                 call writeln(1,'max')
  122.                 cnt=0
  123.                 do until eof(1)
  124.                         text=readln(1)
  125.                         call writeln(2,text)
  126.                         if text='Missing argument.' then leave
  127.                         else do
  128.                                 if address()='REXX' then CMD text
  129.                                 else do
  130.                                         select
  131.                                                 when left(text,6)='*** No' then CMD '/echo No Matches Found.'
  132.                                                 when left(text,6)='*** Ad' then CMD '/echo Additional Matches Found (use higher -m value for more).'
  133.                                                 when comd='say' then CMD '/msg #amiga '||text
  134.                                                 otherwise CMD '/'||comd||' '||text
  135.                                         end
  136.                                 end
  137.                         end
  138.                         cnt=cnt+1
  139.                         if (cnt>=maxsend)&(upper(comd)~='ECHO') then leave
  140.                 end
  141.                 call writeln(1,'quit')
  142.         end
  143.         else CMD '/echo Error opening TCP:'
  144. end
  145. else CMD '/echo You need AmiTCP installed in the proper directories, or mount TCP:'
  146.