pro sxt_plan,week, time, tabname, passn, numtabs, ut=ut
;+
;   Name: sxt_plan
;
;   Purpose: show or return info about SXT table load plan.
;
;   Restrictions:
;      assume that table plans are in $ys/sxt/doc/
;                  named: YY_WW.plan
;
;   History:
;      ~15-apr-95 proto for demo (show_contacts overlay, planning)
;       16-may-95 generic
;-

; initialize
time=''
tabname=''
passn=-1
numtabs=0

case 1 of 
   data_chk(week,/string): weekstr=week
   n_elements(week) eq 0:  weekstr=anytim2weekid(!stime,/string)
   else: begin
     pr_week2tim,week,t0,t1  
     weekstr=anytim2weekid(t0,/string)
   endelse
endcase
numtabs=0
planf=(concat_dir('$DIR_SXT_DOC',strmid(weekstr,0,5)+'.plan'))(0)

plan=rd_tfile(planf)
if plan(0) eq '' then begin
   message,/info,"No plan file: " + planf
   return
endif
remtab,plan,plann		; tab=>spaces

display=keyword_set(display) or n_params() le 1

if display then prstr,strjustify(plan,/box)
 
plann=strupcase(plann)

; define uniq table flag 
tables=(strpos(plann,' P') ne -1) and strpos(plann,':') ne -1 and $
       (strpos(plann,'-') ne -1)

tab=where(tables,cnt)

if cnt eq 0 then message,/info,"Cannot parse table information..." else begin
   loadtab=plann(tab)
   tab=str2cols(str_replace(str_replace(loadtab,'(',' '),')',' '))
   time =fmt_tim(tab(1,*) + ' ' + tab(2,*))     
   if keyword_set(ut) then time=ut_time(time)
   passn=fix(tab(3,*))
   tabname=strtrim(strmid(loadtab,35,100),2)
   numtabs=n_elements(tabname)   
endelse
return
end
