home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 12 / MA_Cover_12.iso / internet / gethelp / rexx / searchhtml.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1999-06-08  |  2.7 KB  |  113 lines

  1. /* SearchHTML.rexx - Search html documents for text
  2. ** $VER: SearchHTML.rexx 0.3 (05.6.99) by B.Rogers <bsrogers@cobweb.com.au>
  3. ** Refer to the GetHelp documentation for usage, version history etc.
  4. **
  5. ** This version is configured for IBrowse ONLY. Lines 24-25 need changing for
  6. ** other browsers - please advise me if you can provide working configurations
  7. ** for other browsers!
  8. **
  9. ** Edit line 17 with the path to your installation of SearchHTML
  10. */
  11.  
  12. /**************************************
  13. ** Set up constants
  14. */
  15.  
  16. RESULTHTML = "_results.html"                            /* temporary results file */
  17. SEARCHHTML = 'C:SearchHTML'                             /* path to SearchHTML */
  18. DeBug=0                                                 /* debug flag */
  19.  
  20. /**************************************
  21. ** Main program
  22. */
  23.  
  24. OPTIONS RESULTS
  25. OPTIONS FAILAT 21
  26.  
  27. /* configure the following lines determine the current url using IBrowse */
  28. ADDRESS "IBROWSE"
  29. QUERY URL
  30.  
  31. /* get current directory of url */
  32. cur_url = RESULT
  33. cur_dir = get_curdir(cur_url)
  34.  
  35. /* change directory to the current html page */
  36. ADDRESS COMMAND
  37. PRAGMA('D',cur_dir)
  38.  
  39. /* delete results from any previous searches */
  40. IF DeBug=1 THEN SAY "deleting old search"
  41. 'delete >NIL:' RESULTHTML
  42.  
  43. /* search the directory for desired data:
  44.    results in RESULTHTML of current directory
  45.    if not file created, SearchHTML was cancelled or quit by user */
  46.  
  47. IF DeBug=1 THEN SAY "starting SearchHTML"
  48. SEARCHHTML
  49. IF DeBug=1 THEN SAY "SearchHTML complete"
  50.  
  51.  
  52. IF EXISTS(RESULTHTML) THEN DO
  53.  
  54.     /* Display results of search url using Openurl */
  55.     'openurl FILE' RESULTHTML
  56.  
  57.     /* delete the results file */
  58.     'delete >NIL:' RESULTHTML
  59. END
  60.  
  61. EXIT
  62.  
  63. /**********************************************************
  64. ** determine directory of loaded url
  65. */
  66.  
  67. get_curdir:
  68.  
  69.   PARSE ARG cur_url
  70.  
  71.   /*
  72.   ** check for file://localhost/, file:///, http:// or ftp:// paths
  73.   */
  74.   pos_local = INDEX(cur_url,"file://localhost/")
  75.   IF pos_local>0 THEN DO
  76.     cur_url=RIGHT(cur_url,LENGTH(cur_url)-17)
  77.     IF debug=1 THEN DO
  78.       SAY "Yep, its a local file [file://localhost/]"
  79.       SAY cur_url
  80.     END
  81.   END
  82.   ELSE DO
  83.     pos_local = INDEX(cur_url,"file:///")
  84.     IF pos_local>0 THEN DO
  85.       cur_url=RIGHT(cur_url,LENGTH(cur_url)-8)
  86.       IF debug=1 THEN DO
  87.         SAY "Yep, its a local file [file:///]"
  88.         SAY cur_url
  89.       END
  90.     END
  91.     ELSE DO
  92.       pos_http = INDEX(cur_url,"http:")
  93.       pos_ftp = INDEX(cur_url,"ftp:")
  94.       IF pos_http>0 OR pos_ftp>0 THEN DO
  95.         SAY "Yep, it's online - future capability enhancement!"
  96.         EXIT
  97.       END
  98.     END
  99.   END
  100.  
  101.   /*
  102.   ** now check for / markers
  103.   */
  104.   pos_dir = LASTPOS("/",cur_url)
  105.   IF pos_dir>0 THEN DO
  106.     path_dir = LEFT(cur_url,pos_dir)
  107.   END
  108.  
  109.   IF debug=1 THEN SAY "cur_dir="path_dir
  110.  
  111. RETURN path_dir
  112.  
  113.