/* Created by Daniel Hellerstein (danielh@crosslink.net), 4/16/01 This OS/2 program is used to search a SWISH index for matches. It will display output using a simple html table, You can also find this program in the goswish ver 1.6 package, see http://www.srehttp.org/apps/goswish/ Simple Usage: x:>swi_html text_to_search where: text_to_search is the text string that swish will look for (text_to_search may contain spaces). (you'll first have to set some default variables in the user-changeable variables section below) For more details, just enter SWI_HTML at and OS/2 command prompt. Note: SWISH-E.EXE must be in your PATH! **************************************************/ /* ---------- USER CHANGEABLE PARAMETERS ------ */ /* row background color for "directory identifier" rows */ color_dir='#cccccc' /* row background color for even # rows */ color_even='#cbebfa' /* row background color for even # rows */ color_odd='#cbf1ab' /* where to write output to */ outfile='vuswish.htm' /* set show_dirs=1 to write directory info to output file */ show_dirs=1 /* swish index file to search */ swish_index='index.swi' /* program (possibly with flags) to use to view results To NOT view results, leave this blank */ viewer='NETSCAPE -l en ' /* ---------- End of USER CHANGEABLE PARAMETERS ------ */ bgs.0=color_even bgs.1=color_odd foo=rxfuncquery('sysloadfuncs') /* load rexxutil library */ if foo=1 then do call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs end aesc='1B'x cy_ye=aesc||'[37;46;m' cyanon=cy_ye normal=aesc||'[0;m' bold=aesc||'[1;m' re_wh=aesc||'[31;47;m' reverse=aesc||'[7;m' parse arg text if text='-?' | text='?' | text='' then do say bold"SWI_HTML"normal" will search a SWISH index, and display the results" say "in HTML format. You can view these results with your favorite browser " say "(and click on links to the underlying files)" say "" say bold"Usage:"normal say " x:>SWI_HTML [-i swish_index] [-o output_file] search_string " say "where: " say ' -i swish_index: (optional) specify a swish ''index'' file to search in' say ' -o output_file: (optional) file to write results to ' say ' search_string: a search string (which may contain AND, OR, etc. modifiers)' say say reverse"Current defaults: "normal say " Index to search: "swish_index say " Resuts written to: "outfile if viewer<>'' then say " Results viewed with: " viewer exit end if pos('-',text)<>'' then do do forever if pos('-',text)=0 then leave parse var text t1 '-' itype text select when translate(itype)='I' then do parse var text swish_Index text end when translate(itype)='O' then do parse var text outfile text end otherwise do say "Unknown option: "itype exit end end end /* do */ if stream(swish_index,'c','query exists')='' then do say bold"ERROR:"normal", no such swish index: "reverse||swish_index||normal exit end say 'Searching 'reverse|| swish_index||normal ' for: ' bold||text||normal address cmd 'SWISH-E.EXE -w 'text' -f 'swish_index' |rxqueue ' if queued()=0 then do say "SWISH produced no output " exit end info.='' ii=0 do until queued()=0 parse pull gooba if gooba='.' then iterate if abbrev(gooba,'#')=1 then do parse var gooba . '#' hdr ':' value hdr=translate(space(hdr,0)) if value='' then iterate aa='!'||hdr info.aa=value iterate end ii=ii+1 lins.ii=gooba end say " # of matches: " ii say "Creating "outfile if stream(outfile,'c','query exists')<>'' then do say ' ' outfile 'exists!' aa=yesno(" Overwrite it ?",,'Y') if aa=1 then do foo=sysfiledelete(outfile) if foo<>0 then do say "Unable to delete (error # "foo exit end end else do say "bye.. " exit end end call lineout outfile,'Swish Index View ' call lineout outfile,'

Viewing Results from Swish Index Search

' call lineout outfile,' ' call lineout outfile,'' call lineout outfile,' ' call lineout outfile,'' if show_dirs=1 then do call lineout outfile,'' call lineout outfile,'' call lineout outfile,'' end else do call lineout outfile,'' call lineout outfile,'' end call lineout outfile,'' fdir0=fdir end if bytes>10000 then bytes=format(bytes/1000,,1)||'k' iseven=1-iseven call lineout outfile,'' if show_dirs=1 then call lineout outfile,'' call lineout outfile,'' call lineout outfile,'' end call lineout outfile,'
Directory
  ScoreFileDescriptionFile size
ScoreFileDescriptionFile size

' /* sample: 1000 M:\SM2\docs/smpind02.txt "smpind02.txt" 1079 936 M:\SM2\docs/smpind00.txt "smpind00.txt" 1277 */ fdir0='' iseven=0 do nn=1 to ii parse var lins.nn score filename '"' adesc '"' bytes fdir=translate(filespec('d',filename)||filespec('p',filename),'\','/') if fdir<>fdir0 & show_dirs=1 then do call lineout outfile,'
'fdir'
'score' ' else call lineout outfile,''score' ' fname=filespec('n',filename) aff=translate(filename,'/','\') aff=translate(aff,'|',':') adesc=strip(adesc,,'"') call lineout outfile,''||fname||''adesc''bytes'
' call lineout outfile,'' call lineout outfile dd=directory() ar1=dd||'/'||translate(outfile,':','|') ar1=translate(ar1,'/','\') foo=viewer' file:///'||ar1 '@start /f 'foo say " >>> starting "foo say ' .... (it might take a few seconds to load)' say "Done! " exit /* -------------------- */ /* choose between 3 alternatives (by default,a yes or no ), return 1 if yes (or 0,1,2 for chosen altenative ) */ yesno:procedure parse arg amessage , altans,def,arrowok ahdr='' if pos('|',amessage)>0 then parse var amessage ahdr '|' amessage aesc='1B'x cy_ye=aesc||'[37;46;m' cyanon=cy_ye normal=aesc||'[0;m' bold=aesc||'[1;m' re_wh=aesc||'[31;47;m' reverse=aesc||'[7;m' aynn=' ' if def='' then defans='' else defans=translate(left(strip(def),1)) if altans='' then altans='No Yes' w.0=words(altans) do iw0=1 to w.0 w.iw0=strip(word(altans,iw0)) a.iw0=translate(left(w.iw0,1)) aa.iw0=substr(w.iw0,2) aynn=aynn||bold if a.iw0=defans then aynn=aynn||cy_ye aynn=aynn||a.iw0||normal||aa.iw0 if iw0