home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / CDTools / S / search.rexx < prev    next >
OS/2 REXX Batch file  |  2000-01-11  |  3KB  |  113 lines

  1. /*
  2.     $VER: Search.rexx 1.0 (31.8.99) (c) Neil Bothwick, Wirenet
  3. */
  4.  
  5. /* ;;; Initialise */
  6. options results
  7. signal on error
  8. call LoadLib('rexxsupport.library')
  9. call LoadLib('rexxdossupport.library')
  10. call LoadLib('rexxreqtools.library')
  11.  
  12. parse arg args
  13. args = compress(args,'a0'x)
  14. do until args = ''
  15.     parse var args a '"' b '"' args
  16.     interpret a||'"'||b||'"'
  17.     args = strip(args,'L')
  18.     end
  19.  
  20. if SearchStr = '' then call ExitMsg('You must give a string to search for')
  21. 'urlencode "'SearchStr'" var SearchEnc'
  22. OutputURL = 'x-aweb:searchresults/'SearchEnc
  23. OutputFile = 'T:CDsearch.results'
  24. AWebPort = address()
  25. if left(AWebPort,5) ~= 'AWEB.' then call ExitMsg('This script can only be run*Nfrom a link inside AWeb')
  26. ;;;
  27. /* ;;; Search */
  28. Search:
  29.     call delete(OutputFile)
  30.     select
  31.         when Source = 'Amigactive' then do
  32.             signal off error
  33.             address command 'FlashFind AACD06:CDTools/indices/AACD06 "'SearchStr'" NH >'OutputFile
  34.             if RC = 5 then Matches = 0
  35.             signal on error
  36.             nop
  37.             end
  38.         when Source = 'Aminet CDs' then do
  39.             nop
  40.             end
  41.         when Source = 'Aminet' then do
  42.             nop
  43.             end
  44.         otherwise nop
  45.         end
  46. /* Show matches or warn if none */
  47. /*
  48. if word(statef(OutFile),2) = 0 then call ReqMsg('No matches found for "'SearchStr'"')
  49. else address command 'Multiview' OutFile
  50. 'gauge id PROGR attrs' MUIA_Gauge_Current 0 MUIA_Gauge_InfoText '""'
  51. return
  52. */
  53. ;;;
  54. /* ;;; Output results */
  55. 'chanopen'  OutputURL
  56. ChanID = result
  57. 'chanheader' ChanID '"Content-Type: text/html"'
  58. 'chanheader' ChanID '"Pragma: No-cache"'
  59. 'chandata' ChanID '"<html><head><title>Search results</title></head><body bgcolor=white>"'
  60. 'chandata' ChanID '"<h3 align=center>Searching for "<font color=red>'SearchStr'</font>" in 'Source'</h2>" newline'
  61. 'open'  OutputURL
  62. 'chandata' ChanID '"<a href=*"file://localhost/AACD06:html/SearchCD.html*">Another search</a><p>" newline'
  63. 'chandata' ChanID '"<table width=*"100%*">" newline'
  64.  
  65. call open(res,OutputFile,'R')
  66. do until eof(res)
  67.     line = readln(res)
  68.     if line = '' then iterate
  69.     parse var line name 34 path
  70.     name = strip(name,'T')
  71.     'chandata' ChanID '"<tr><td><a href=*"x-aweb:rexx/REXX:AAShowDir 'PathPart(path)'*">'name'</a><td>'path'" newline'
  72.     end
  73. 'chandata' ChanID '"</table>" newline'
  74. 'chandata' ChanID '"<p><a href=*"file://localhost/AACD06:html/SearchCD.html*">Another search</a>" newline'
  75. 'chandata' ChanID '"</body></html>" newline'
  76. 'chanclose' ChanID
  77. call close(res)
  78. 'open'  OutputURL
  79. ;;;
  80. /* ;;; Cleanup and exit */
  81. CleanUp:
  82.     call delete(OutputFile)
  83.     call close(res)
  84.     exit
  85. ;;;
  86. /* ;;; Exit with a message */
  87. ExitMsg:
  88.     parse arg msg
  89.     call ShowMsg(msg)
  90.     call CleanUp()
  91.     return
  92. ;;;
  93. /* ;;; Error handler */
  94. Error:
  95.     call ExitMsg('Error' RC 'in line' sigl)
  96.     return
  97. ;;;
  98. /* ;;; Show a message in a requester */
  99. ShowMsg:
  100.     parse arg msg
  101.     'request "Amigactive CD" "'msg'" "OK" nowait'
  102.     return
  103. ;;;
  104. /* ;;; Load library */
  105. LoadLib:
  106.     parse arg library
  107.     if show('L',library) then return
  108.     if ~exists('LIBS:'library) then address command 'copy AACD06:System/libs/'library 'LIBS: clone quiet'
  109.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  110.     return
  111. ;;;
  112.  
  113.