pro sxhcopy, h, keyword1, keyword2, hout ;-------------------------------------------------------------------------- ; ; make keywords 8 characters long (upper case) ; key1 = strmid(strupcase(keyword1+' '),0,8) key2 = strmid(strupcase(keyword2+' '),0,8) ; ; get header lengths ; n = n_elements(h) nout = n_elements(hout) ; ; find position of first keyword in h ; i1 = 0 while i1 lt n do begin key = strmid(h[i1],0,8) if key1 eq key then goto,found1 if key eq 'END ' then begin print,'SXHCOPY -- keyword '+key1+' not found in header.' print,' Nothing copied to output header.' return endif i1 = i1+1 endwhile found1: ; ; find position of second keyword ; i2 = i1 while i2 lt n do begin key = strmid(h[i2],0,8) if key eq 'END ' then begin i2 = i2-1 ;do not copy 'END ' goto,found2 endif if key2 eq key then goto,found2 i2 = i2+1 endwhile found2: ; ; find end of output header ; i = 0 while i lt nout do begin if strmid(hout[i],0,8) eq 'END ' then goto,found i = i+1 endwhile message,'No END keyword found in output header' found: ; ; create new output header ; if i gt 0 then hout=[hout[0:i-1],h[i1:i2],hout[i]] $ else hout=[h[i1:i2],hout[i]] return end