pro uvsp_catreset, str=str, out=out, input=input
common cat_parse_time, time

  ;
  ; Is this a full scale reset or an item by item reset
  ;

  if n_elements(input) eq 0 then input='RESET'  ; this means reset everything

  case 1 of
     (strmid(input,0,5) eq 'RESET' )  : input=strmid(input,5,99)
     (strmid(input,0,4) eq 'RESE' )   : input=strmid(input,4,99)
     (strmid(input,0,3) eq 'RES' )    : input=strmid(input,3,99)
     else : ; something is very wrong
  endcase 

 input =  strcompress(strtrim(input,2),/remove_all)
 if (strmid(input,0,1) eq ',') or (strmid(input,0,1) eq '=') $
    then input = strmid(input, 1, 3) $      ; lose delimeter
    else input = strmid(input, 0, 3)
  
 if input eq '' or input eq '/AL' then input='ALL'

 case input of
  'ALL' : begin
       if n_elements(time) ne 0 then begin
           time.yr=0   & time.doy=0 & time.mon=1 
       time.day=20 & time.hr=19 & time.min=1
       endif

       str = {screen, $
    range_flag    : 0,                                 $  ; 0=time,1=exp #
    exp           : '1-99771',                         $  ; exp # range
    tim           : '80-Feb-20 19:01 - 89-Nov-17 11:23', $  ; time range
    name          : '',             $  ; definition name
    type          : '1-21',                         $  ; exp types
    slit          : '1-22',                      $  ; slit #
    det           : '1-5',                           $  ; detector #
    spec          : 'NO',                          $  ; spectra only?
    wld           : '0-7500',              $  ; # WLD postions
    angs          : '1000-3600',           $  ; wavelength 
    shft          : '0-60',                     $   ; calibration WLD shift
    intvl         : '0-255',                    $   ; calibration interval
    noaa          : '0-16,2287-5786',       $   ; code or AR
    rsun          : '0.00-3.50',                $ 
    xpix          : '0-255',            $   ; X image size ranges
    ypix          : '0-255',            $   ; Y image size ranges
    xres          : '0-32',             $   ; X pixel resolution
    yres          : '0-32',             $   ; Y pixel resolution
    pol           : 'A,B,O',            $   ; pol  A, B or OUT
    npol          : '0-16',                     $   ; # pol positions
    dur           : '0-13300'}                  ; Exp duration range

       out = {where, $
    ran_min       : 0l,     $  ; minimum exp index currently selected
    ran_max       : 99770l, $  ; maximum exp index currently selected
    exp           : 0b, $  ; exp # range
    tim           : 0b, $  ; time range
    name          : 0b, $  ; definition name
    type          : 0b, $  ; exp types
    slit          : 0b, $  ; slit #
    det           : 0b, $  ; detector #
    spec          : 0b, $  ; spectra only?
    wld           : 0b, $  ; # WLD postions
    angs          : 0b, $  ; wavelength 
    shft          : 0b, $  ; calibration WLD shift
    intvl         : 0b, $  ; calibration interval
    noaa          : 0b, $  ; target codes or active region
    rsun          : 0b, $ 
    xpix          : 0b, $  ; X image size ranges
    ypix          : 0b, $  ; Y image size ranges
    xres          : 0b, $  ; X pixel resolution
    yres          : 0b, $  ; Y pixel resolution
    pol           : 0b, $  ; pol  A, B or OUT
    npol          : 0b, $  ; # pol positions
    dur           : 0b, $  ; Exp duration range
    man           : '' }  ; manual input from the user
       end

  'RAN':begin
    str.exp = '1-99771'                 ; exp # range
    str.tim = '80-Feb-20 19:01 - 89-Nov-17 11:23'   ; time range
    out.exp = 0b                    ; exp # range
    out.tim = 0b                    ; time range
    out.ran_min = 0
    out.ran_max = 99770

        if n_elements(time) ne 0 then begin
           time.yr=0   & time.doy=0 & time.mon=1 
       time.day=20 & time.hr=19 & time.min=1
        endif
    end

  'NAM':begin 
    str.name = ''                   ; definition name
    out.name = 0b                   ; definition name
    end

  'TYP':begin                              
    str.type = '1-21'               ; exp types
    out.type = 0b                   ; exp types
    end

  'SLI':begin
    str.slit = '1-22'               ; slit #
    out.slit = 0b                   ; slit #
    end

  'DET':begin
        str.det = '1-5'                 ; detector #
        out.det = 0b                    ; detector #
        end

  'SPE':begin
        str.spec = 'NO'                 ; spectra only?
        out.spec = 0b                   ; spectra only?
        end

  'WLD':begin
    str.wld = '0-7500'              ; # WLD postions
    out.wld = 0b                    ; # WLD postions
    end

  'ANG':begin
    str.angs = '1000-3600'              ; wavelength 
    out.angs = 0b                   ; wavelength 
    end

  'SHI':begin
    str.shft = '0-60'               ; calibration WLD shift
    out.shft = 0b                   ; calibration WLD shift
    end

  'INT':begin
    str.intvl= '0-255'              ; calibration interval
    out.intvl= 0b                   ; calibration interval
    end

  'NOA':begin
    str.noaa    = '0-16,2287-5786'          ; active regions
    out.noaa    = 0b                    ; active regions
    end

  'RSU':begin
    str.rsun = '0.00-3.50' 
    out.rsun = 0b                   
    end

  'XPI':begin
    str.xpix  = '0-255'                 ; X image size ranges
    out.xpix  = 0b                  ; X image size ranges
    end

  'YPI':begin
    str.ypix = '0-255'              ; Y image size ranges
    out.ypix = 0b                   ; Y image size ranges
    end

  'XRE':begin
    str.xres  = '0-32'              ; X pixel resolution
    out.xres  = 0b                  ; X pixel resolution
    end

  'YRE':begin
    str.yres  = '0-32'              ; Y pixel resolution
    out.yres  = 0b                  ; Y pixel resolution
    end

  'POL':begin
    str.pol  = 'A,B,O'              ; pol  A, B or OUT
    out.pol  = 0b                   ; pol  A, B or OUT
    end

  'NPO':begin
    str.npol  = '0-16'              ; # pol positions
    out.npol  = 0b                  ; # pol positions
    end

  'DUR':begin
    str.dur  = '0-13300'                    ; Exp duration range
    out.dur  = 0b                       ; Exp duration range
    end

  'MAN':begin
    out.man  = ''                       ; no manual input
    end

 else : if n_elements(comment) eq 0 then print,'Invalid RESET command, "'+input+'".'

 endcase
return
end