home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / CDTools / S / search.rexx < prev    next >
OS/2 REXX Batch file  |  1999-10-07  |  3KB  |  112 lines

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