home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 14 / AACD14.ISO / CDTools / S / QuickSearch.awebrx < prev    next >
Text File  |  2000-09-21  |  3KB  |  75 lines

  1. /*
  2.     $VER: QuickSearch.awebrx 1.2 (28.3.00) (c) Neil Bothwick, Wirenet
  3.     QuickSearch - Searches the index of the current CD
  4. */
  5.  
  6. /* ;;; Initialise */
  7. options results
  8. CDname = 'AACD14:'
  9. IndexFile = CDName'CDTools/indices/'compress(CDName,':')
  10. TempFile = 'T:QuickSearch.temp'
  11. ResultFile = 'T:QuickSearch.html'
  12. if ~show('L','rexxsupport.library') then call addlib('rexxsupport.library',0,-30,0)
  13. if ~show('L','rexxdossupport.library') then call addlib('rexxdossupport.library',0,-30,0)
  14.  
  15. AWebPort = address()
  16. if ~abbrev(AWebPort,'AWEB.') then do
  17.     do i = 1 to 25
  18.         if show('P','AWEB.'i) then do
  19.             AWebPort = 'AWEB.'i
  20.             leave
  21.             end
  22.         end
  23.     if ~abbrev(AWebPort,'AWEB.') then exit
  24.     address(AWebPort)
  25.     end
  26. 'get url target=main'
  27. OldPage = result
  28. 'open file://localhost/'CDName'html/Searching.html target main reload'
  29. ;;;     
  30. /* ;;; Search index file */
  31. parse arg SearchStr
  32. if abbrev(SearchStr,'SearchStr="') then parse var SearchStr . '="' SearchStr '"'
  33. SearchStr = translate(SearchStr,' ','+')
  34. address command CDName'System/C/FlashFind >'TempFile IndexFile '"'SearchStr'" NOPREFS QUIET NH'
  35. if RC > 0 then Found = 'NO'
  36. ;;;     
  37. /* ;;; Open output file and write headers */
  38. call open(out,ResultFile,'W')
  39. call writeln(out,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">')
  40. call writeln(out,'<html><head><title>Search results</title></head><body bgcolor=white>')
  41. call writeln(out,'<p><h4 align="center"><a href="'OldPage'">Return to previous page</a></h4><p>')
  42. call writeln(out,'<h3 align=center>Result of searching for "<font color=red>'SearchStr'</font>"</h3>')
  43. ;;;
  44. /* ;;; Process result into HTML */
  45. if Found = 'NO' then do
  46.     call writeln(out,'<h3 align=center>No matches found for "<font color=red>'SearchStr'</font>" on this CD</h3>')
  47.     call writeln(out,'<p><h4 align="center">Would you like to <a href="file://localhost/'CDName'html/SearchCDs.html">Search other CDs</a> or</h4><p>')
  48.     end
  49. else do
  50.     call open(in,TempFile,'R')
  51.     call writeln(out,'<table width="100%">')
  52.     do until eof(in)
  53.         line = readln(in)
  54.         if line = '' then iterate
  55.         parse var line name =34 path
  56.         name = strip(name)
  57.         line = '<tr><td>'name'<td><a href="x-aweb:rexx/'left(path,pos(':',path))'CDTools/S/AAShowDir 'PathPart(path)'">'path'</a>'
  58.         call writeln(out,line)
  59.         end
  60.     call writeln(out,'</table>')
  61.     end
  62. call writeln(out,'<p><h4 align="center"><a href="'OldPage'">Return to previous page</a></h4><p>')
  63. call writeln(out,'</body></html>')
  64. ;;;  
  65. /* ;;; Close files and load into AWeb */
  66. call close(in)
  67. call close(out)
  68. address command 'delete >NIL:' TempFile
  69. 'open file://localhost/'ResultFile' target main reload'
  70. 'wait file://localhost/'ResultFile
  71. address command 'delete >NIL:' ResultFile
  72. ;;;
  73. exit
  74.  
  75.