octave-maintainers
[Top][All Lists]
Advanced

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

Re: new function: textscan.m


From: John W. Eaton
Subject: Re: new function: textscan.m
Date: Sat, 23 Oct 2010 02:13:12 -0400

On 22-Oct-2010, Michael D Godfrey wrote:

| On 10/22/2010 10:47 PM, John W. Eaton wrote:
| 
|     Ah, good idea, I had forgotten about that feature.  I'll check in the
|     follwoing function:
|     
|       function retval = is_valid_file_id (fid)
|     
|         retval = false;
|     
|         if (nargin == 1)
|           try
|             [file, mode, arch] = fopen (fid);
|             retval = ! isempty (file);
|           end_try_catch
|         else
|           print_usage ();
|         endif
|     
|       endfunction
|     
|     Thanks,
|     
|     jwe
|     
| Just a question: is there any need to do an fclose(fid) after the
| fopen(fid) ?

No, this usage of fopen just checks the status of FID.  It doesn't
actually open a file.  Or at least it is not supposed to.  But I see
now that there is no check on nargout in fopen, and the way the logic
is for handling the (stupid Matlab compatible) fopen ("all") case,
something like

  [file, mode, arch] = fopen ("file")

will actually open "file" for reading if it exists.  I'll fix that so
that if nargout == 3 and nargin == 1, we will only perform the status
check.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]