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