;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Get extension with given name (proNameArg) and compile it ;;; - if compiling it fails, get source from fcb file FITS extension ;;; - if getting source from extension fails, throw error via MESSAGE, ... pro DIcal_IrProCheck, proNameArg, fcb, is_function=is_funcArg $ , debug=debugArg noDebug = keyword_set(debugArg) ? 0b : 1b ;;; Build procedure name ('x') and filename ('x.pro') from proNameArg ('X') lowerPN = strlowcase(proNameArg) iw = stregex( lowerPN, '\.pro$') if iw ge 0L then lowerPN = strmid(lowerPN, 0L, iw) proFilename = lowerPN + '.pro' ;;; Try to compile code, return if it succeeds or is already compiled if dical_resolveroutine(lowerPN,is_func=is_funcArg,/no_recompile) then return ;;; To here, initial compilation failed, so extract IDL code from extension lun=-1L ;;; File LUN to write if needed catcher=0L if noDebug then catch,catcher if catcher ne 0L then begin ;;; setup error handling catch,/cancel msg = !error_state.msg if lun gt 0L then free_lun,lun message,'OPENW/WRITEU/COMPILE failed on file '+fcb.filename+'('+proName+'); '+msg return ;;; Redundant endif ;;; Extract ASCII bytes from extension FITS_READ,fcb,proBytes,proHdr,EXTNAME=proNameArg,/NO_ABORT,MESSAGE=msg if msg ne '' then $ message,'FITS_READ failed on file '+fcb.filename+'('+proNameArg+'); '+msg ;;; Write ACII bytes to file openw,lun,proFilename,/get_lun writeu,lun,proBytes free_lun,lun lun = -1L ;;; Try compiling again, throw error on failure if not dical_resolveroutine(lowerPN,is_func=is_funcArg,/no_recompile) then $ message,!error_state.msg,/noname return ;;; success end