home *** CD-ROM | disk | FTP | other *** search
- /* SearchHTML.rexx - Search html documents for text
- ** $VER: SearchHTML.rexx 0.3 (05.6.99) by B.Rogers <bsrogers@cobweb.com.au>
- ** Refer to the GetHelp documentation for usage, version history etc.
- **
- ** This version is configured for IBrowse ONLY. Lines 24-25 need changing for
- ** other browsers - please advise me if you can provide working configurations
- ** for other browsers!
- **
- ** Edit line 17 with the path to your installation of SearchHTML
- */
-
- /**************************************
- ** Set up constants
- */
-
- RESULTHTML = "_results.html" /* temporary results file */
- SEARCHHTML = 'C:SearchHTML' /* path to SearchHTML */
- DeBug=0 /* debug flag */
-
- /**************************************
- ** Main program
- */
-
- OPTIONS RESULTS
- OPTIONS FAILAT 21
-
- /* configure the following lines determine the current url using IBrowse */
- ADDRESS "IBROWSE"
- QUERY URL
-
- /* get current directory of url */
- cur_url = RESULT
- cur_dir = get_curdir(cur_url)
-
- /* change directory to the current html page */
- ADDRESS COMMAND
- PRAGMA('D',cur_dir)
-
- /* delete results from any previous searches */
- IF DeBug=1 THEN SAY "deleting old search"
- 'delete >NIL:' RESULTHTML
-
- /* search the directory for desired data:
- results in RESULTHTML of current directory
- if not file created, SearchHTML was cancelled or quit by user */
-
- IF DeBug=1 THEN SAY "starting SearchHTML"
- SEARCHHTML
- IF DeBug=1 THEN SAY "SearchHTML complete"
-
-
- IF EXISTS(RESULTHTML) THEN DO
-
- /* Display results of search url using Openurl */
- 'openurl FILE' RESULTHTML
-
- /* delete the results file */
- 'delete >NIL:' RESULTHTML
- END
-
- EXIT
-
- /**********************************************************
- ** determine directory of loaded url
- */
-
- get_curdir:
-
- PARSE ARG cur_url
-
- /*
- ** check for file://localhost/, file:///, http:// or ftp:// paths
- */
- pos_local = INDEX(cur_url,"file://localhost/")
- IF pos_local>0 THEN DO
- cur_url=RIGHT(cur_url,LENGTH(cur_url)-17)
- IF debug=1 THEN DO
- SAY "Yep, its a local file [file://localhost/]"
- SAY cur_url
- END
- END
- ELSE DO
- pos_local = INDEX(cur_url,"file:///")
- IF pos_local>0 THEN DO
- cur_url=RIGHT(cur_url,LENGTH(cur_url)-8)
- IF debug=1 THEN DO
- SAY "Yep, its a local file [file:///]"
- SAY cur_url
- END
- END
- ELSE DO
- pos_http = INDEX(cur_url,"http:")
- pos_ftp = INDEX(cur_url,"ftp:")
- IF pos_http>0 OR pos_ftp>0 THEN DO
- SAY "Yep, it's online - future capability enhancement!"
- EXIT
- END
- END
- END
-
- /*
- ** now check for / markers
- */
- pos_dir = LASTPOS("/",cur_url)
- IF pos_dir>0 THEN DO
- path_dir = LEFT(cur_url,pos_dir)
- END
-
- IF debug=1 THEN SAY "cur_dir="path_dir
-
- RETURN path_dir
-
-