; Open a journal file with a unique name pro journ,file,directory=directory common cjourn,cfile ; If a journal is open, close it if !journal gt 0 then begin print,'closing journal file ',cfile journal ; remove Amiga graphics and the last "journ" command spawn,"sed -e '//d' -e '/^journ$/d' "+cfile+" > "+cfile+".tmp ; mv "+cfile+".tmp "+cfile if n_elements(file) eq 0 then return end ; If no file given, make a name based on the date and time if n_elements(file) eq 0 then begin spawn,/noshell,['/bin/date','+%y%m%d.%H%M.jou'],timestr file=timestr(0) if keyword_set(directory) then begin if directory eq 1 then directory='~/idl_journals' file=directory+'/'+file end end ; check so we don't overwrite an existing file openr,lun,/get,file,err=err if err ge 0 then begin close,lun free_lun,lun print,file,' exists, overwrite ?' a='n' read,a if a ne 'y' then return end print,"journal,'"+file+"'" journal,file cfile=file end