pro pr_pnt_hist, starttime, stoptime, outfil=outfil
;
;+
;NAME:
;	pr_pnt_hist
;PURPOSE:
;	To list the Yohkoh S/C commanded pointing history
;SAMPLE CALLING SEQUENCE:
;	pr_pnt_hist
;	pr_pnt_hist, outfil='pr_pnt_hist.txt'
;	pr_pnt_hist, /outfil
;OPTIONAL KEYWORD INPUT:
;	outfil	- The name of the output file to be written to.  If it
;		  is an integer, it will use the file 'pr_pnt_hist.txt'
;HISTORY:
;	Written Jul-93 by M.Morrison
;	 5-Aug-93 (MDM) - Modified to print the header information when running
;			  interactively (not just when writing to a file)
;       21-nov-94 (SLF) - add start and stop time input parameters
;                         buffer data
;-
;
tit = ['PR_PNT_HIST  Ver 1.4 (5-Aug-93) ', $
	'Program Run: ' + !stime, $
	'  ', $
	'* The following values are the number of arcminutes the S/C is offset', $
	'  relative to a fixed reference.  ', $
	'* Used the following "nominal" 1993 pointing value as the reference', $
	'       93JAN26  23:31:00 - 23:31:05    FBC3 0161 0000 ( -3.6   1.2   0.0)', $
	'* A negative S/C E/W pointing offset causes the SXT images to move to the ', $
	'  east (left on the image).  (The S/C moves to the west ?)', $
	'* A negative S/C N/S pointing offset causes the SXT images to move to the ', $
	'  south (down on the image).  (The S/C moves to the north ?)', $
	'  ', $
	'      Starting          Duration     S/C Pointing offset (arcminutes)', $
	'     Date/Time        (days/hours)         E/W       N/S       Roll', $
        ; 2-SEP-91  23:19:32      0 /  3.4         60.023     5.783     0.000
	'  ']
;
common pr_pnt_hist_blk, pdata

qoutfil = 0
if (keyword_set(outfil)) then begin
    qoutfil = 1
    ;
    siz = size(outfil)
    typ = siz( siz(0)+1 )
    if (typ ne 7) then outfil = 'pr_pnt_hist.txt'
    ;
    openw, lun, outfil, /get_lun
    prstr, tit, lun
end
;
;
ref = [      70.6000,     -217.000,      0.00000]
;

if n_elements(pdata) eq 0 then begin
   rd_pnt_hist, data
   pdata=data
endif else data = pdata

if n_params() gt 0 then begin
   if n_params() eq 1 then stoptime=!stime
   ss=sel_timrange(data,starttime,stoptime,/between)
   if ss(0) eq -1 then begin
      message,/info,"No pointing history record between specified times...
      return
   endif
   data=data(ss)
endif

n = n_elements(data)
;

outbuff=tit

for i=0,n-1 do begin
    if (i eq n-1) then begin
	dt = '          ....' 
    end else begin
	dt = int2secarr(data(i+1), data(i))/86400	;converted to days
	days = fix(dt)
	hours = (dt-days)*24
	dt = string(days, hours, format='(4x, i3, " /", f5.1)')
    end
    dp = (data(i).offset - ref)/60.
    str = fmt_tim(data(i)) + dt + string(dp, format='(5x, 3f10.3)')
    outbuff=[outbuff,str]
    if (qoutfil) then printf, lun, str
end
prstr,outbuff,/nomore
;
if (qoutfil) then free_lun, lun
end
