Opening a file with ACTION='READ' 
Author Message
 Opening a file with ACTION='READ'

Suppose a file is opened with ACTION='READ' and the
file does not exist.  Should the OPEN statement fail
with an error, or should an empty file be created?

                                Sincerely,
                                Bob Corbett



Wed, 23 Jan 2008 14:41:47 GMT  
 Opening a file with ACTION='READ'

Quote:

> Suppose a file is opened with ACTION='READ' and the
> file does not exist.  Should the OPEN statement fail
> with an error, or should an empty file be created?

>                            Sincerely,
>                            Bob Corbett

I'd say fail.  I'd certainly want it to. Dunno what the standard says,
if anything.

--
Cheers - Dave.



Fri, 25 Jan 2008 13:21:18 GMT  
 Opening a file with ACTION='READ'


Quote:

> > Suppose a file is opened with ACTION='READ' and the
> > file does not exist.  Should the OPEN statement fail
> > with an error, or should an empty file be created?

> I'd say fail.  I'd certainly want it to. Dunno what the standard says,
> if anything.

I have trouble keeping track of the fine distinctions in things like
files that are connected but do not exist and so forth. But I'm pretty
sure that the standard doesn't have a dependence on action= in that
regard.

I'd normally expect something opened with action='read' to also have
status='old'. In that case, it should be an error if the file doesn't
exist - that's what status='old' does. But for action='read' without
status='old'? I don't think I see that as ipso facto an error - just a
strange thing to do.

The status, if unmentioned, is 'unknown', which typically causes a file
to be created if it doesn't exist. I could picture not creating the
file, but then giving an error if a read from the non-existent file is
attempted. Seems to me that there is no error if you open the file, but
don't actually read from it.

But mostly, I think that action='read' without status='old' is a
silly thing for a program to do, and I wouldn't expect an
implementation to go out of its way to special-case it.



Fri, 25 Jan 2008 13:44:01 GMT  
 Opening a file with ACTION='READ'

Dave Weatherall schreef:

Quote:

> > Suppose a file is opened with ACTION='READ' and the
> > file does not exist.  Should the OPEN statement fail
> > with an error, or should an empty file be created?

F95 standard ;  9.3.4.8
... For a new file, the processor creates the file wwith a
set of allow3ed actions that includes the specified action.

So, NO error until you try to read from the new empty file .

[JvO]

Quote:
> >                               Sincerely,
> >                               Bob Corbett

> I'd say fail.  I'd certainly want it to. Dunno what the standard says,
> if anything.

> --
> Cheers - Dave.



Fri, 25 Jan 2008 16:23:49 GMT  
 Opening a file with ACTION='READ'

Quote:
>> Should the OPEN statement fail with an error, or should an
>> empty file be created?
> I'd say fail.  I'd certainly want it to. Dunno what the standard says,
>  if anything.

I was careless in my use of Standardese.  I shouldn't have asked if
it should fail with an error, I should have asked if it should fail
with
an error condition.  There is no error here.

The fortran standard allows an implementor to choose what
constitutes an input/output error condition.  An implementation
could cause an input/output error condition to occur for every
input/output statement and still be standard-compliant.  The
Fortran committee would call it (and has called it)  a
quality-of-implementation (QOI) issue.

Bob Corbett



Sat, 26 Jan 2008 06:48:15 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ACTION='read' in OPEN statement

2. opening 'file open' dialog from console

3. "Error 1 when trying to open and read datalog file from several subVi's

4. Can't open/read flat file db

5. Intellimouse Returns 'File Not Open'

6. cannot open include file 'param.inc'

7. file = open(path,'wb')?????

8. Input via OPEN(5,file='..')

9. Used to 'file = open(...)', now what?

10. Used to 'file = open(...)', now what?

11. File Reading in 'J'

12. 'wav' files reading

 

 
Powered by phpBB® Forum Software