Re: openr and /get_lun [message #19733] |
Mon, 17 April 2000 00:00  |
Nando Iavarone
Messages: 48 Registered: December 1998
|
Member |
|
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Craig Markwardt wrote:
<blockquote TYPE=CITE>I have noticed that the use of /GET_LUN and ERROR
keywords to openr is
<br>not as helpful as I would have hoped. Do other have this experience?
<br>The problem is that when an error occurs, it is hard to know whether
<br>the file unit was "gotten" or not.
<p>For example:
<p>pro test1
<br> openr, unit, filename, /get_lun, error=err
<br> free_lun, unit
<br>end
<p>If there was an error, then it is possible that UNIT was never set,
<br>and is hence undefined. FREE_LUN doesn't take undefined variables.
<p>If there is error checking to do, I don't know exactly what it should
<br>be. So I find myself explicitly doing this instead:
<p>pro test2
<br> get_lun, unit
<br> openr, unit, filename, error=err
<br> free_lun, unit
<br>end
<p>Comments?
<br> </blockquote>
Hi Craig,
<br>you have to trap the error.
<br>it is the open that can fail, so you have to check the err variable:
<p>pro test2
<br> get_lun, unit
<br> openr, unit, filename, error=err
<br> if (err le 0) then begin
<br> ;error management
<br> ...............................
<br> endif
<br> free_lun, unit
<br>end
<br>
<br>
<pre>You can also use the more flexible error trapping CATCH procedure.</pre>
<pre>It is general and not only for file management:</pre>
<pre></pre>
pro testOpen<br>
errorStatus=0<br>
catch,errorStatus<br>
if errorStatus ne 0 then begin
<br>
;error management<br>
print,!ERR_STRING<br>
return<br>
endif<br>
openr,lun,'pippone',/get_lun<br>
free_lun,lun<br>
end
<br>
<pre>--
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040 Frascati - RM
Tel: +39-6-944091 (switchboard)
9440968 (direct)
E-mail:
f.iavarone@acsys.it
FrdndVrn@altavista.net</pre>
</html>
|
|
|