;+
;
; NAME: 
;	UVSP_CATSCREEN
;
; PURPOSE:
;       Process the command line inputs from the screen version of the
;	UVSP catalog search program.
;
; CATEGORY:
;       UVSP Catalog
;
; CALLING SEQUENCE:
;       UVSP_CATSCREEN
;
; CALLED BY:
;       UVSPCAT
;
; CALLS TO:
;	UVSP_CATRESET, UVSP_CATSHOW, UVSP_CATHELP, UVSP_CATREAD 
;
; INPUTS:
;       none
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       none
;
; OPTIONAL OUTPUTS:
;	none
;
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	Display screen version menu and process commands that the user enters.
;
; MODIFICATION HISTORY:
;	July 1993 - Elaine Einfalt (HSTX)
;
;-




pro UVSP_CATSCREEN, str=str, out=out, nofull=nofull

 input = ''

 uvsp_catshow,  str=str  			; display non-widget menu

 repeat begin

   read, 'Enter Command > ', input
     input = strupcase(strcompress(input)) + ';'	; end of line terminator

     start_pos = 0 
     repeat begin 

       end_pos = strpos(input, ';', start_pos)

       line = strtrim(strmid(input, start_pos, end_pos-start_pos),2) 

       case 1 of
	(line eq '')  		      : ; do nothing
	(strmid(line,0,4) eq 'HELP')  : UVSP_CATHELP, input=strmid(line,4,99)
	(strmid(line,0,3) eq 'HEL' )  : UVSP_CATHELP, input=strmid(line,3,99)
        (strmid(line,0,3) eq 'SHO' )  : UVSP_CATSHOW, str=str, out=out, line=line
        (strmid(line,0,3) eq 'LIS' )  : UVSP_CATSHOW, str=str, out=out, line=line
	(strmid(line,0,3) eq 'EXI' )  : end_pos = -1         
	(strmid(line,0,3) eq 'RES' )  : UVSP_CATRESET, str=str, out=out, input=line
	(strmid(line,0,3) eq 'SEA' )  : uvsp_catread, out=out, str=str, nofull=nofull
	(strmid(line,0,2) eq 'GO'  )  : uvsp_catread, out=out, str=str, nofull=nofull
	else  :	UVSP_CATPARAM, str=str, out=out, input=line, nofull=nofull
       endcase

       start_pos = end_pos + 1		; ready for next command 
     endrep until (end_pos eq -1)       ; until "EXIT" or no more commands

  endrep until (strmid(line,0,3) eq 'EXI')

print, 'Terminating SMM/UVSP catalog search program.'

return
end

;==========================================================================

;+
;
; NAME: 
; 	UVSP_CATSHOW
;
; PURPOSE:
;       Prints the catalog menu to the screen, displaying the commands and
;	current parameter settings.
;
; CATEGORY:
;       UVSP Catalog
;
; CALLING SEQUENCE:
;       UVSP_CATSHOW, STR=STR
;
; CALLED BY:
;       UVSPSCREEN
;
; CALLS TO:
;	none
;
; INPUTS:
;       STR :	structure of strings containing the current values of the
;		search parameters
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       none
;
; OPTIONAL OUTPUTS:
;	none
;
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	Print each line of the screen version of the UVSP catalog search menu.
;
; MODIFICATION HISTORY:
;	July 1993 - Elaine Einfalt (HSTX)
;
;-

pro uvsp_catshow, str=str, out=out, line=line

  if n_elements(line) ne 0 then $   		; special case of SHOW
     if strupcase(strmid(line,5,3)) eq 'MAN' then begin
	if out.man eq '' then print,'No MAN parameters.' $
	                 else print,'Current value of MAN:',out.man
	return
     endif

  dots = '.................................................'
  ndot = 22				; a spacing size for screen menu 

  print,''
  print,'Command  Value.................Description'
  print,''

  if str.range_flag eq 0 then $
       print, 'RAN   ', str.tim, strmid(dots,0,(ndot-strlen(str.tim))>0),    $
	          '...Time range (or use experiment #)' $
  else print, 'RAN   ', str.exp,  strmid(dots,0,(ndot-strlen(str.exp))>0), $
	          '...Experiment range (or use time YY/MM/DD HH:MM)'


  print,'NAME  ', str.name, strmid(dots,0,(ndot-strlen(str.name))>0), $
		 '...Part of experiment definiton name (C4, CAL, BURST)'

  print,'TYPE  ', str.type, strmid(dots,0,(ndot-strlen(str.type))>0), $
		 '...Experiment types'

  print,'SLIT  ', str.slit, strmid(dots,0,(ndot-strlen(str.slit))>0), $
	       	 '...Slit values'
                              
  print,'DET   ', str.det, strmid(dots,0,(ndot-strlen(str.det))>0), $
	     	 '...Detectors in combination and individual'

  print,'XPIX  ', str.xpix, strmid(dots,0,(ndot-strlen(str.xpix))>0), $
		 '...X direction image size range in pixels (NX)'

  print,'YPIX  ', str.ypix, strmid(dots,0,(ndot-strlen(str.ypix))>0), $
		 '...Y direction image size range in pixels (NY)'

  print,'XRES  ', str.xres, strmid(dots,0,(ndot-strlen(str.xres))>0), $
		 '...X direction resolution (DX) (arcsec/pixel)'

  print,'YRES  ', str.yres, strmid(dots,0,(ndot-strlen(str.yres))>0), $
		 '...Y direction resolution (DY) (arcsec/pixel)'

  print,'SPEC  ',  str.spec, strmid(dots,0,(ndot-strlen(str.spec))>0), $
		 '...Spectra only, including PMs and RLs (Y or N)'
                
  print,'ANGS  ', str.angs, strmid(dots,0,(ndot-strlen(str.angs))>0), $
		'...Wavelength ranges in angstroms'

  print,'WLD   ' + str.wld, strmid(dots,0,(ndot-strlen(str.wld))>0), $
		'...Number of WLD steps'

  print,'SHIFT ' + str.shft, strmid(dots,0,(ndot-strlen(str.shft))>0), $
		'...Calibration WLD shift'

  print,'INTVL ', str.intvl, strmid(dots,0,(ndot-strlen(str.intvl))>0), $
		'...Calibration interval'

  print,'POL   ', str.pol, strmid(dots,0,(ndot-strlen(str.pol))>0), $
		'...Polarimeter status (O is OUT)'

  print,'NPOL  ', str.npol, strmid(dots,0,(ndot-strlen(str.npol))>0), $
		'...Number of polarimeter steps'

  print,'DUR   ', str.dur, strmid(dots,0,(ndot-strlen(str.dur))>0), $
		'...Duration range(s) in minutes (orbit=~60 min)'

  print,'RSUN  ', str.rsun, strmid(dots,0,(ndot-strlen(str.rsun))>0), $ 
		'...Radial distance range(s) from sun center'

  print,'NOAA  ', str.noaa, strmid(dots,0,(ndot-strlen(str.noaa))>0), $
		'...Target (see HELP NOAA) or NOAA active region'


  print,''
  PRINT,'Enter: <command> <value>; SHOW; SEARCH; RESET <command>; EXIT; or HELP <topic>

return
end

