[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: openr and /get_lun



In article <on66tglhxl.fsf@cow.physics.wisc.edu>,
	Craig Markwardt <craigmnet@cow.physics.wisc.edu> writes:
>
> I totally agree that the error condition must be handled.  What I was
> getting at is that OPENR, ..., /GET_LUN does two things: allocate a
> LUN, and open a file.  If you get an ERROR condition back, it's
> impossible to know which of these two things failed.  In fact in the
> above example you gave, the unit FL may be undefined, so FREE_LUN will
> fail.

You can tell which of these things failed based on the
name of the  error that is returned in the !ERROR_STATE
structure.  The documentation  states that although the 
error code number (a negative integer) can change across IDL 
sessions, the error name cannot. 
  
  ;== The program TEST.PRO tries to open many files, 
  ;== each with a different unit number, and stops
  ;== if there is an error

  IDL> .RUN TEST                      
  % Stop encountered:  $MAIN$
  IDL> PRINT, error                  
        -234
  IDL> HELP, !ERROR_STATE.NAME
  <Expression>    STRING    = 'IDL_M_FILE_NOLUNLEFT'
  IDL> PRINT, !ERROR_STATE.MSG
  OPENW: All available logical units are currently in use.
  IDL>
  IDL> CLOSE, /ALL
  IDL>
  IDL> OPENR, fl, 'nofile', /GET_LUN, ERROR = error
  IDL> PRINT, error
        -222
  IDL> PRINT, !ERROR_STATE.NAME
  <Expression>    STRING    = 'IDL_M_CNTOPNFIL'
  IDL> PRINT, !ERROR_STATE.MSG
  OPENR: Error opening file. Unit: 100, File: nofile


Regards,
 
-bob

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Robert S. Mallozzi                                       256-544-0887
                                                      Mail Code SD 50
http://gammaray.msfc.nasa.gov/           Marshall Space Flight Center 
http://cspar.uah.edu/~mallozzir/                 Huntsville, AL 35812
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~