PRO sortparm,day,debug=dbg ; This small procedure reads a temporary file holding header data from all ; images acquired on the given day of the month, and writes it out in time ; order to s permanent file. path='\IDL\DATA\' ds=STRING(day,FORMAT='(I2.2)') searchname=path+'????'+ds+'.TMP' IF KEYWORD_SET(dbg) THEN PRINT,'search name=',searchname f=FINDFILE(searchname,COUNT=nf) CASE nf OF 0: BEGIN MESSAGE,'No files found matching the given day!' RETURN END 1: BEGIN PRINT,'Opening '+f(0) inname=f(0) END ELSE: BEGIN FOR i=0,nf-1 DO PRINT,STRTRIM(i,2),' ',f(i) PRINT,'Enter the number of the file you want to process' i0=-1 READ,i0 PRINT,'Opening '+f(i0) inname=f(i0) END ENDCASE IF KEYWORD_SET(dbg) THEN STOP,'inname=',inname,'; .con to continue' OPENR,in,inname,/GET_LUN ; Now read lines from the file until we run out of data ut=FLTARR(3000) & parms=INTARR(26,3000) ut1=1.0 & parms1=INTARR(26) nlines=0 REPEAT BEGIN READU,in,ut1,parms1 ut(nlines)=ut1 parms(*,nlines)=parms1 nlines=nlines+1 ENDREP UNTIL EOF(in) CLOSE,in & FREE_LUN,in ut=ut(0:nlines-1) parms=parms(*,0:nlines-1) IF KEYWORD_SET(dbg) THEN PRINT,'nlines=',nlines ; Now sort UT to determine how the parameters should be sorted. timeord=SORT(ut) ut=ut(timeord) IF KEYWORD_SET(dbg) THEN STOP,'Check parms, then .con' parms=parms(*,timeord) IF KEYWORD_SET(dbg) THEN STOP,'Check parms, then .con' ; Now write out the time-ordered parameters outname=inname STRPUT,outname,'SRT',STRLEN(outname)-3 OPENW,out,outname,/GET_LUN FOR i=0,nlines-1 DO WRITEU,out,ut(i),parms(*,i) CLOSE,out & FREE_LUN,out ; Last thing: delete the temporary file SPAWN,'DEL '+inname RETURN END