⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fdosfile.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 5 页
字号:
.chap *refid=fdosfil &product File Handling
.*
.np
.ix 'file handling'
.ix 'file naming'
This chapter describes the file handling and naming conventions of
&cmpname..
We discuss
.us files
and
.us devices
which are used to store, retrieve and display data.
For example, a disk can be used to store a file of student marks.
This file is accessible by other programs in order to produce
summaries of the data such as marks reports.
A device such as a printer can also be treated as if it were a file,
although it is only useful for displaying data; an attempt to read
information from this device is invalid.
.np
In the following sections, we shall describe:
.autopoint
.point
the techniques that &cmpname adopts for implementing
.us FORMATTED
and
.us UNFORMATTED
records and
.us SEQUENTIAL
and
.us DIRECT
access to these records,
.point
the handling of "print" files,
.point
file naming conventions,
.point
logical file names,
.point
the preconnection of files to units, and
.point
special device support.
.endpoint
.*
.section Record Access
.*
.np
.ix 'record access'
Two types of record access are supported by &cmpname:
.begpoint
.point Sequential
Sequential access means that records in a file are accessed in order,
starting with the first record in the file and proceeding to the
last.
Sequential access is permitted to records in both variable-length and
fixed-length record files.
.point Direct
Direct access means that records in a file are accessed in random
order.
For example, the fifth record could be accessed, then the second,
and then the tenth.
Direct access is permitted for fixed-length record files only.
.endpoint
.np
The access method is described using the
.kw ACCESS=
specifier of the FORTRAN
.kw OPEN
statement.
The default access is "SEQUENTIAL".
.*
.section Record Format
.*
.np
.ix 'record format'
.ix 'formatted record'
.ix 'unformatted record'
.ix 'formatted record'
.ix 'record' 'unformatted'
There are two record formats, "FORMATTED" and "UNFORMATTED", which
are supported by &cmpname..
The record format is described using the
.kw FORM=
specifier of the FORTRAN
.kw OPEN
statement.
The default format is "FORMATTED" for files connected for sequential
access and "UNFORMATTED" for files connected for direct access.
.np
In describing these two formats, we also refer to the two methods
of record access, "SEQUENTIAL" and "DIRECT", which are supported
by &cmpname..
.beglevel
.*
.section FORMATTED Records
.*
.np
.ix 'formatted record'
.ix 'record' 'formatted'
A
.us FORMATTED
record is one that contains an arbitrary number of ASCII characters.
The end of a record is marked by an ASCII "LF" (line feed) character
optionally preceded by an ASCII "CR" (carriage return) character.
Thus this special sequence may not appear in the middle of a record.
.np
FORMATTED records may vary in length.
If all the records in the file have the same length then the records
may be accessed both "sequentially" and "directly".
If the records vary in length then it is only possible to access the
records sequentially.
.np
For direct access, the length of the records is specified by the
.kw RECL=
specifier of the FORTRAN
.kw OPEN
statement.
The specified length must not include the record separator since
it does not form part of the record.
.np
As an extension to the FORTRAN 77 language standard, &cmpname also
supports the use of the
.kw RECL=
specifier for sequential access.
The maximum length of the records may be specified by the
.kw RECL=
specifier of the FORTRAN
.kw OPEN
statement.
The specified length must not include the record separator since
it does not form part of the record.
The length is used to allocate a record buffer for sequential access.
If the record length is not specified, a default maximum length of 1024
characters is assumed.
.*
.section UNFORMATTED Records
.*
.np
.ix 'unformatted record'
.ix 'record' 'unformatted'
An
.us UNFORMATTED
record is one that contains an arbitrary number of binary storage
units.
The interpretation of the data in such a record depends on the FORTRAN
program that is processing the record.
An UNFORMATTED record may contain integers, real numbers, character
strings, or any other type of FORTRAN data.
.np
UNFORMATTED records may also vary in length.
If all records in the file have the same length then the records may
be accessed both "sequentially" and "directly".
If the records vary in length then it is only possible to access the
records sequentially.
.np
When a file containing UNFORMATTED records is accessed sequentially,
each record must begin and end with a descriptor that contains the
length of the record.
The length of the record is represented in 32 bits or 4 bytes
(INTEGER*4).
The UNFORMATTED records of a file which are written using sequential
access will be automatically supplied with the appropriate length
descriptors.
When such a file is read, it is assumed that each record has the
appropriate length descriptors.
.np
Depending on the record length, the output produced by a single
unformatted sequential
.kw WRITE
statement may cause multiple records to be written.
As previously mentioned, each record begins and ends with a length
descriptor.
The length descriptors for the first record contain the length of the
record.
The length descriptors for the remaining records contain the length of
the record with the high bit (bit 31) set to one.
In this way, an unformatted sequential file can be viewed as a number
of logical records (a logical record corresponding to the output
produced by a
.kw WRITE
statement) with each logical record composed of a number of physical
records.
Files created in this way cannot be accessed directly unless each
logical record is composed of a single physical record and each record
is the same size.
.np
As an extension to the FORTRAN 77 language standard, &cmpname also
supports the use of the
.kw RECL=
specifier for sequential access.
The maximum length of the records may be specified by the
.kw RECL=
specifier of the FORTRAN
.kw OPEN
statement.
The specified length must not include the length descriptors since
they do not form part of the record.
The length is used to allocate a record buffer for sequential access.
If the record length is not specified, a default maximum length of 1024
characters is assumed.
.np
When a file containing UNFORMATTED records is accessed directly, each
record must be the same length.
In this case, the length of the records is specified by the
.kw RECL=
specifier of the FORTRAN
.kw OPEN
statement.
If the file was originally created with sequential access then the
specified length must include any length descriptors which form part
of the record.
In the direct access mode, no interpretation is placed on any of the
data in an UNFORMATTED record and the programmer must account for any
record length descriptors which may form part of the record.
.np
Any records which are written using direct access must include record
length descriptors if the file is to be accessed sequentially at a
later time.
As an alternative, you may specify
.id RECORDTYPE='VARIABLE'
in the FORTRAN
.kw OPEN
statement.
This specifier is an extension to the FORTRAN 77 language standard
and will cause length descriptors to be generated automatically.
In this case, the record length should not include the record length
descriptors.
.*
.section Files with no Record Structure
.*
.np
Certain files, for example a file created by a program written in
another language, do not have any internal record structure that
matches any of the record structures supported by &cmpname..
These files are simply streams of data.
There are two ways in which these files can be processed.
.autonote
.note
You can use unformatted direct access.
In this case, the value specified by the
.kw RECL=
specifier in the
.kw OPEN
statement determines the amount of data read or written by a
.kw READ
or
.kw WRITE
statement.
.note
Alternatively, you can use unformatted sequential access.
In this case, the amount of data read or written to the file is determined
by the items in the input/output list of the
.kw READ
or
.kw WRITE
statement.
When using unformatted sequential access, you must specify
.mono RECORDTYPE='FIXED'
to indicate that no record boundaries are present.
Otherwise, the default value of
.mono 'VARIABLE'
will be used.
.endnote
.endlevel
.*
.section Attributes of Files
.*
.np
The file system does not retain any information on the
contents of a file.
Unlike more sophisticated file systems, it cannot report whether a
file consists of fixed-length or variable-length records, how records
are delimited in a file, the maximum length of the records, etc.
Therefore, we have provided a mechanism which will allow you to
specify additional information about a file.
This mechanism should be used when the default assumptions about
records in a file are not true for the file in question.
.np
The
.kw RECORDTYPE=
specifier of the FORTRAN
.kw OPEN
statement can be used to specify additional information about the
type of records in the file.
This specifier is an extension to the FORTRAN 77 language standard.
.np
The
.kw RECL=
specifier of the FORTRAN
.kw OPEN
statement can be used to specify additional information about the
length of records in the file.
When used with sequential access, this specifier is an extension to
the FORTRAN 77 language standard.
.np
The
.kw CARRIAGECONTROL=
specifier of the FORTRAN
.kw OPEN
statement can be used to specify additional information about the
handling of ASA carriage control characters for an output file.
This specifier is an extension to the FORTRAN 77 language standard.
.np
The
.kw BLOCKSIZE=
specifier of the FORTRAN
.kw OPEN
statement can be used to specify the size of the internal input/output
buffer.
A buffer reduces the number of system input/output calls during
input/output to a particular file and hence improves the overall
performance of a program.
The default buffer size is 4K.
This specifier is an extension to the FORTRAN 77 language standard.
.np
The following sections describe the attributes of records supported by
the &cmpname run-time system.
.beglevel
.*
.section Record Type
.*
.np
.ix 'record type'
The
.kw RECORDTYPE=
specifier of the FORTRAN
.kw OPEN
statement can be used to specify additional information about the
type of records in the file.
This specifier is an extension to the FORTRAN 77 language standard.
The following types may be specified.
.millust begin
RECORDTYPE='TEXT'
RECORDTYPE='VARIABLE'
RECORDTYPE='FIXED'
.millust end
.begnote
.*========
.note TEXT
.*========
.ix 'RECORDTYPE' 'TEXT'
.ix 'TEXT record type'
indicates that the file contains variable-length or fixed-length
records of ASCII characters separated by an ASCII "LF" (line feed) character
optionally preceded with an ASCII "CR" (carriage return) character.
By default, the &cmpname run-time system assumes that
.kw FORMATTED
records are of
.kw TEXT
format in both the
.us sequential
and
.us direct
access modes.
.np
By default, the &cmpname run-time system uses variable-length record
.kw TEXT
files to implement
.kw FORMATTED
records in the
.us sequential
access mode.
Of course, all records may be the same length.
The record separator is not included in calculating
the maximum size of records in the file.
.np
By default, the &cmpname run-time system uses fixed-length record
.kw TEXT
files to implement
.kw FORMATTED
records in the
.us direct
access mode.
Each record must be the same length.
The record separator is not included in calculating
the size of records in the file.
.*============
.note VARIABLE
.*============
.ix 'RECORDTYPE' 'VARIABLE'
.ix 'VARIABLE record type'
indicates that the file contains variable-length or fixed-length
records in which special descriptors are employed to describe the length of
each record.
The length of each record is contained in a doubleword (INTEGER*4
item) at the beginning and end of the record.
These descriptors determine the bounds of the records.
.np
By default, the &cmpname run-time system uses
.kw VARIABLE
format files to implement
.kw UNFORMATTED
records in the
.us sequential
access mode.
The length descriptors are required to support the FORTRAN
.kw BACKSPACE
statement since no other method exists for determining the bounds of a
variable-length unformatted record in a file.
.*=========

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -