INQUIRE - FORM vs. (UN)FORMATTED
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
INQUIRE - FORM vs. (UN)FORMATTED         


Author: Tobias Burnus
Date: Dec 8, 2006 01:16

Hello,

I'm trying to understand the FORM, FORMATTED and UNFORMATTED specifiers
of INQUIRE.

Let's start with FORM:
"The scalar-default-char-variable in the FORM= specifier is assigned
the value FORMATTED if the file is connected for formatted
input/output, and is assigned the value UNFORMATTED if the file is
connected for unformatted input/output. If there is no connection, it
is assigned the value UNDEFINED."

Ok, this is clear to me. Especially, it means given a UNIT (or a FILE
name) I can determine whether a file is connected and, if yes, whether
I need to access it as unformatted or formatted. I see many uses for
procedures where the UNIT is passed.

Ok, now comes the specifiers for which I don't understand what is (a)
exactly the purpose and (b) what value should be assigned when. (I talk
about FORMATTED below, but with UNFORMATTED I have exactly the same
problems.)
Show full article (3.10Kb)
5 Comments
Re: INQUIRE - FORM vs. (UN)FORMATTED         


Author: nospam
Date: Dec 8, 2006 09:15

Tobias Burnus wrote:
> I'm trying to understand the FORM, FORMATTED and UNFORMATTED specifiers
> of INQUIRE.
>
> Let's start with FORM:..
> Ok, this is clear to me. Especially, it means given a UNIT (or a FILE
> name) I can determine whether a file is connected and, if yes, whether
> I need to access it as unformatted or formatted.

Well... I don't like your use of "need" there. While correct, I find it
potentially misleading. It tells you whether the file was opened (aka
connected) with formatted or unformatted. You "need" to use the way that
corresponds to the current open, but this says nothing about whether or
not you might also be able to use the other way on the same file with a
different open (at a different time).
> First case: INQUIRE(NAME=existing_file,...), which is not
> connected/opened. Well, "UNKNOWN" can of cause always returned, but are
> there scenarios where one would return FORMATTED="YES" or "NO"?
Show full article (5.82Kb)
no comments
Re: INQUIRE - FORM vs. (UN)FORMATTED         


Author: Tobias Burnus
Date: Dec 8, 2006 09:31

Hello,

Tobias Burnus wrote:
> Ok, now comes the specifiers for which I don't understand what is (a)
> exactly the purpose and (b) what value should be assigned when. (I talk
> about FORMATTED below, but with UNFORMATTED I have exactly the same
> problems.)

Ok, I found something about this from 1998:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/661e9ecf0a.../

Namely the answer by Richard Main to the question: "Is there another
way (portable) to check if file is formatted or unformatted?"

* * *

"Closer to what you are asking for are the FORMATTED= and
UNFORMATTED= specifier in INQUIRE. THey tell you whether the
file can be connected for formatted or unformatted I/O. Note
that it is possible for both of them to return "YES". It
is also allowed for them to return "UNKNOWN", which means
that you can't count on them to be definitive.
Show full article (1.99Kb)
no comments
Re: INQUIRE - FORM vs. (UN)FORMATTED         


Author: glen herrmannsfeldt
Date: Dec 8, 2006 10:43

Richard Maine wrote:
> Tobias Burnus wrote:
>> I'm trying to understand the FORM, FORMATTED and UNFORMATTED specifiers
>> of INQUIRE.
(snip)
> Certainly. I suspect you must be thinking of implementation issues for
> current operating systems, because the answer seems so obvious in
> general. If the file can definitely be opened as a formatted file, it
> returns yes. If it definitely cannot be, it returns no. But I just
> restated what th e standard said without even changing the words much. I
> can't think of a more obvious way to say it.
> Now most current operating systems don't have a good way to tell. So I
> suspect most compilers will probably return unknown. That's likely the
> practical answer.

For OS derived from OS/360, UNFORMATTED must be RECFM=VBS and
FORMATTED must not be VBS. I believe that VMS also has record
format information in its file system that could be used.

Unix and DOS/Windows only give a stream of bytes which must
contain any information needed.
Show full article (1.44Kb)
no comments
Re: INQUIRE - FORM vs. (UN)FORMATTED         


Author: robert.corbett
Date: Dec 8, 2006 23:56

Tobias Burnus wrote:
> Hello,
>
> I'm trying to understand the FORM, FORMATTED and UNFORMATTED specifiers
> of INQUIRE.

One of the nastier cases arises when a file is implicitly
opened as a result of a BACKSPACE, ENDFILE, or
REWIND statement on a unit that is not yet connected
to a file. In Fortran 90/95, the file would be known to be
sequential access, but whether it was formatted or
unformatted would not be determined. In Fortran 2003,
it is no longer known to be sequential access.

Implicitly opening files is an extension to the standard,
but because it was the only way to open files in
FORTRAN 66, many programs did it. Most modern
Fortran implementations still support such usage.

Bob Corbett
1 Comment
Re: INQUIRE - FORM vs. (UN)FORMATTED         


Author: Jim
Date: Dec 10, 2006 10:23

"Dr Ivan D. Reid" brunel.ac.uk> wrote in message
news:slrnennlsj.2ui.Ivan.Reid@loki.brunel.ac.uk...
> On 9 Dec 2006 23:52:02 -0800, Terence cantv.net>
> wrote in <1165737122.248963.160370@l12g2000cwl.googlegroups.com>:
>> Nor the operating system nor even the compiler matters, as long as the
>> external storage device is capable of being written and read by one
>> unit of strorage (usually a multiple-of-8 bit wide datum) at a time, or
>> an equivalence to that can be constructed in intermediary hardware or
>> software programming.
>
> Try doing that on OpenVMS...
>
>
> --
> Ivan Reid, School of Engineering & Design, _____________ CMS
> Collaboration,
> Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12,
> CERN
> KotPT -- "for stupidity above and beyond the call of duty".
Just to amplify, the Record Management System (through which nearly all file ...
Show full article (1.54Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
RE: single form or continuous formsmicrosoft.public.access.forms ·