Viewing contents of file '../idllib/deutsch/local/mk_local_help2.pro'
pro mk_local_help2,dummy
;+
; NAME:
;   MK_LOCAL_HELP2
; PURPOSE:
;   This program converts the large HTML help files generated by mk_local_help
;   (using RSI's mk_html_help) to "one liner" help files where each procedure
;   gets only a few lines of description instead of the whole header.
; CALLING SEQEUNCE:
;   mk_local_help2
; NOTES:
;   This program should be run on bluemoon (where all the IDL libraries
;   reside). 
;-

  files=findfile('libr*.html', $
    count=nfiles)

  for i=0,nfiles-1 do begin
;  for i=1,1 do begin
    openr,1,files(i)
    openr,2,files(i)
    openw,3,'s'+files(i)
    print,files(i)
    lin=''
    while (lin ne '<UL>') do begin
      readf,1,lin & readf,2,lin
      if (lin eq '<body>') then lin='<body bgcolor="#ffffff" link="#ee0000" vlink="#992200" text="#00000">'
      if (strmid(lin,0,9) eq 'This page') then begin
	printf,3,'The following is a listing of the entire contents of this library for IDL.'
	printf,3,'Click on an individual procedure name to view its header and '
	printf,3,'source code.  This listing'
	printf,3,'is a shortened form of the much longer <A HREF="'+files(i)+'">'
	printf,3,'entire library help file</A>.  This may be handy for'
	printf,3,'text searchs, be beware that some of these are huge and may take a long'
	printf,3,'time to load or even crash your browser.<P>'
	printf,3,''
	printf,3,'<H3>[<A HREF="http://www.astro.washington.edu/deutsch/idl/htmlhelp/index.html">Go Back to Main Search Page</A>]</H3>'
	printf,3,'<HR SIZE=5 noshade>'
        while (strmid(lin,0,8) ne '<STRONG>') do begin
          readf,1,lin & readf,2,lin
          endwhile
        endif
      if (strmid(lin,0,3) eq '<HR') then lin=''
      printf,3,lin
      endwhile

    readf,1,lin
    while (lin ne '</UL><P>') do begin
      fname=strmid(lin,strpos(lin,'>',6)+1,99)
      fname=strmid(fname,0,strpos(fname,'<',0))
      if (fname eq '') then goto,SKIP4
      lin2=''
      while (lin2 ne '<A NAME="'+fname+'">') do readf,2,lin2
      if EOF(2) then goto,BAIL
      hdr=strarr(500) & hi=0
      lin2=''
      while (lin2 ne '</PRE><P>') and (hi lt 497) do begin
        readf,2,lin2
        hdr(hi)=lin2
        hi=hi+1
        endwhile
      hdr=hdr(0:hi-1)
      get_purpose,hdr,purp
      printf,3,'<LI><A HREF="/deutsch-bin/getpro/'+files(i)+'?'+fname+ $
        '">'+fname+'</A> '+purp
SKIP4:
      readf,1,lin
      endwhile

    printf,3,lin
    printf,3,'</body>'
    printf,3,'</html>'

    close,/all
    endfor

  return

BAIL:
  print,'aaacccckkkkk!!!!!  bad things, pally..'
  stop

end


pro get_purpose,hdr,purp

  nel=n_elements(hdr)
  hdr=[hdr,'','']
  nlin=0
  sep='' & purp=''

  for i=0,nel-1 do begin
    lin=strtrim(strupcase(strcompress(hdr(i),/remove)),2)
    stopflag=0
    if (strmid(lin,0,7) eq 'PURPOSE') or (lin eq '*PURPOSE:') or $
       (lin eq 'DESCRIPTION:') or (lin eq 'DESCRIPTION') or $
       (lin eq 'EXPLANATION:') or (lin eq 'EXPLANATION') then begin
      i=i+1
      while (nlin lt 10) and (stopflag eq 0) do begin
        if (strlen(strn(hdr(i))) le 13) or (strpos(hdr(i),'CALLING SEQ') ne -1) then begin
          stopflag=1
          i=i-1
          endif $
        else begin
          purp=purp+sep+strtrim(hdr(i),2) & nlin=nlin+1 & sep=' ' & i=i+1
          endelse
        endwhile
      endif
    endfor

  if (nlin ne 0) then return

  i=0
  nlin=0
  purp=''
  while (hdr(i) ne "<PRE>") and (i lt nel) do i=i+1
  while (nlin lt 6) and (i lt nel) do begin
    if (strlen(hdr(i)) ge 10) then begin
      purp=purp+' '+strtrim(hdr(i),2)
      nlin=nlin+1
      endif
    i=i+1
    endwhile
  if (purp eq '') then purp='????'

  return

end