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

📄 fdosfile.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 5 页
字号:
:cmt. JBSOne file handle is required by DOS for every open file.
:cmt. JBS.ix 'FILES='
:cmt. JBS.ix 'DOS' 'FILES='
:cmt. JBS.ix 'CONFIG.SYS'
:cmt. JBS.ix 'DOS' 'CONFIG.SYS'
:cmt. JBSUnder DOS, the maximum number of file handles available to all
:cmt. JBSprocesses executing in the personal computer is controlled by the
:cmt. JBS"FILES=" statement of the DOS
:cmt. JBS.bd CONFIG.SYS
:cmt. JBSfile (this file must be placed in the root directory of the boot
:cmt. JBSdisk).
:cmt. JBSIn the absence of
:cmt. JBS.bd CONFIG.SYS
:cmt. JBSfile, DOS will allocate 8 file handles by default.
:cmt. JBSThis default may be altered using the "FILES=" statement in the DOS
:cmt. JBS.bd CONFIG.SYS
:cmt. JBSfile.
:cmt. JBSThis special DOS file must be placed in the root directory of the boot
:cmt. JBSdisk.
:cmt. JBSThe "FILES=" parameter defines the total number of file handles for
:cmt. JBSall processes in your system.
:cmt. JBS.np
:cmt. JBSUnder DOS, each process can use a maximum of 20 file handles
:cmt. JBSnumbered 0, 1, up to 19.
:cmt. JBSFile handles 0 through 4 are preassigned by DOS to the standard input,
:cmt. JBSoutput, error, auxiliary, and printer devices.
:cmt. JBSFile handles 5 through 19 (a total of 15 handles) are also available
:cmt. JBSfor use by the &cmpname run-time system.
:cmt. JBSThus an additional 15 files can be opened by the &cmpname run-time
:cmt. JBSsystem, provided that you have specified a large enough number of file
:cmt. JBShandles in the "FILES=" statement in the
:cmt. JBS.bd CONFIG.SYS
:cmt. JBSfile.
:cmt. JBS.np
:cmt. JBSAs we stated above, one file handle is used for each open file.
:cmt. JBSUnder DOS 2.x, 3 files are permanently opened, thus 3 file handles are
:cmt. JBSalready in use.
:cmt. JBSUnder DOS 3.x or later, 4 files are permanently opened, thus 4 file
:cmt. JBShandles are already in use.
:cmt. JBSIf you use DOS input and output redirection using the "<" and ">"
:cmt. JBScharacters then additional file handles will be used by DOS thereby
:cmt. JBSreducing the number available to the &cmpname run-time system.
:cmt. JBS.np
:cmt. JBSThus, if you specify "FILES=10" in the DOS
:cmt. JBS.bd CONFIG.SYS
:cmt. JBSfile,
:cmt. JBSthe following table describes the number of file handles available
:cmt. JBSto the &cmpname run-time system for file input/output.
:cmt. JBS.millust begin
:cmt. JBS                      DOS 2.x   DOS 3.x or later
:cmt. JBSwithout "<" and ">"      7         6
:cmt. JBSwith "<"                 6         5
:cmt. JBSwith ">"                 6         5
:cmt. JBSwith both "<" and ">"    5         4
:cmt. JBS.millust end
:cmt. JBS.np
:cmt. JBSSince each file opened by the &cmpname run-time system requires a DOS
:cmt. JBSfile handle,
:cmt. JBSthe maximum number of files which can be opened by the &cmpname
:cmt. JBSrun-time system at one time can be calculated as:
:cmt. JBS.millust begin
:cmt. JBSif FILES=n then
:cmt. JBS    (under DOS 2.x)
:cmt. JBS        min(15, n - 3 - NumberOf(std i/o redirections))
:cmt. JBS    (under DOS 3.x or later)
:cmt. JBS        min(15, n - 4 - NumberOf(std i/o redirections))
:cmt. JBS.millust end
:cmt. JBS.pc
:cmt. JBSprovided that no other tasks have opened any files.
:cmt. JBSFor example, if you have specified "FILES=20" and you are using
:cmt. JBSa DOS 3.x system then the maximum number of file handles available
:cmt. JBSto your program is 20 &minus 4 = 16.
:cmt. JBSSince the run-time system can use a maximum of 15 handles (5 through
:cmt. JBS19), there is an adequate number of handles to open 15 files.
:cmt. JBSOn the other hand, if you have specified "FILES=15" and you are using
:cmt. JBSa DOS 3.x system then the maximum number of file handles available to
:cmt. JBSyour program is 15 &minus 4 = 11.
:cmt. JBSSince the run-time system can use a maximum of 15 handles (5 through
:cmt. JBS19) and 11 are available, only 11 files can be opened.
:cmt. JBS.np
:cmt. JBSTo calculate the number of DOS file handles that should be allocated,
:cmt. JBSconsider that the following files will be open when a FORTRAN program
:cmt. JBSbegins execution.
:cmt. JBS.begpoint
:cmt. JBS.point (i)
:cmt. JBS.ix 'standard input'
:cmt. JBS.ix 'DOS standard input'
:cmt. JBSThe DOS "Standard Input" file is already opened by DOS and is preconnected
:cmt. JBSto unit 5 by the &cmpname run-time system.
:cmt. JBS.point (ii)
:cmt. JBS.ix 'standard output'
:cmt. JBS.ix 'DOS standard output'
:cmt. JBSThe DOS "Standard Output" file is already opened by DOS and is preconnected
:cmt. JBSto unit 6 by the &cmpname run-time system.
:cmt. JBS.point (iii)
:cmt. JBS.ix 'standard error'
:cmt. JBS.ix 'DOS standard error'
:cmt. JBSThe DOS "Standard Error" file is already opened by DOS
:cmt. JBS(used by the &cmpname run-time system to issue messages).
:cmt. JBS.point (iv)
:cmt. JBS.ix 'standard auxiliary'
:cmt. JBS.ix 'DOS standard auxiliary'
:cmt. JBSUnder DOS 3.x or later, the "Standard Auxiliary" file is already opened.
:cmt. JBS.* .point (v)
:cmt. JBS.* .ix 'unit 5'
:cmt. JBS.* Unit 5 is opened by the &cmpname run-time system at execution-time if
:cmt. JBS.* any input/output statement references this file.
:cmt. JBS.* .exam
:cmt. JBS.* READ *, X, Y
:cmt. JBS.* .eexam
:cmt. JBS.* .point (vi)
:cmt. JBS.* .ix 'unit 6'
:cmt. JBS.* Unit 6 is opened by the &cmpname run-time system at execution-time if
:cmt. JBS.* any input/output statement references this file.
:cmt. JBS.* .exam
:cmt. JBS.* PRINT *, 'Enter a number'
:cmt. JBS.* .eexam
:cmt. JBS.endpoint
:cmt. JBS.np
:cmt. JBSIn addition, the following files could be open.
:cmt. JBS.begpoint
:cmt. JBS.point (v)
:cmt. JBS.ix 'standard input ' 'redirection'
:cmt. JBSAnother file is opened by DOS if standard input redirection ("<") was
:cmt. JBSspecified on the command line.
:cmt. JBS.point (vi)
:cmt. JBS.ix 'standard output ' 'redirection'
:cmt. JBSAnother file is opened by DOS if standard output redirection (">") was
:cmt. JBSspecified on the command line.
:cmt. JBS&cmpname run-time system error messages which are normally printed
:cmt. JBSon the screen will appear in the specified file.
:cmt. JBS.endpoint
:cmt. JBS.np
:cmt. JBSFiles (i) through (vi), that we have described above, each require
:cmt. JBSrequire DOS file handles.
:cmt. JBS.np
:cmt. JBSUnder DOS 2.x, a typical situation is where files (i), (ii) and (iii)
:cmt. JBSabove are already opened by DOS.
:cmt. JBSThis gives a total of 3 open files.
:cmt. JBSIf the current maximum number of DOS file handles is 8 then at most 5
:cmt. JBSmore files can be opened by the executing FORTRAN program.
:cmt. JBS.ix 'FILES='
:cmt. JBS.ix 'DOS' 'FILES='
:cmt. JBS.ix 'CONFIG.SYS'
:cmt. JBS.ix 'DOS' 'CONFIG.SYS'
:cmt. JBSIf 7 more files are to be opened by the executing program then the
:cmt. JBSremedy is to specify "FILES=10" in the DOS
:cmt. JBS.bd CONFIG.SYS
:cmt. JBSfile and then reboot the personal computer.
:cmt. JBSUnder DOS 3.x or later, another file (iv) is open so we must specify
:cmt. JBS"FILES=11".
:cmt. JBS.endlevel
.*
.section Terminal or Console Device Support
.*
.np
.ix 'terminal device'
.ix 'console device'
.ix 'device' 'console'
Input can come from the console or output can be written to the
console by using the console device name :FNAME.con:eFNAME. as the
file name.
The console can be specified in a "SET" command or
through the
.kw FILE=
specifier of the FORTRAN
.kw OPEN
statement.
.np
.ix 'CON' 'Win32'
.ix 'Win32' 'CON'
The default action for any file is to open the file for both read and
write access (i.e., ACTION='READWRITE').
Under Win32, there is a problem accessing the console device
:FNAME.con:eFNAME. for both read and write access.
This problem is overcome by using the
.kw ACTION=
specifier in the
.kw OPEN
statement.
The
.kw ACTION=
specifier indicates the way in which the file is initially accessed.
The values allowed for the
.kw ACTION=
specifier are the following.
.begnote
.note 'READ'
the file is opened for read-only access
.note 'WRITE'
the file is opened for write-only access
.note 'READWRITE'
the file is opened for both read and write access
.endnote
.np
To open the console device under Win32, you must specify whether you
are going to "READ" or "WRITE" to the file.
If you wish to do both reading and writing, then you must use two
separate units.
.exam begin
OPEN( UNIT=1, FILE='CON', ACTION='READ')
OPEN( UNIT=2, FILE='CON', ACTION='WRITE')
.exam end
.np
The console can be treated as a carriage control device.
This is requested by using the
.mono CARRIAGECONTROL='YES'
specifier of the FORTRAN
.kw OPEN
statement.
.exam begin
OPEN( UNIT=1, FILE=':FNAME.con:eFNAME.', CARRIAGECONTROL='YES' )
.exam end
.np
Carriage control handling is described in the
section entitled :HDREF refid='fdospfa'..
.np
The console is not capable of supporting carriage control in a
fashion identical to a printer.
For example, overprinting of records on the console is destructive in
that the previous characters are erased.
.np
End of file is signalled by first pressing the Ctrl/Z key combination
and then the line entering key.
End of file may be handled by using the
.kw END=
specification of the
FORTRAN
.kw READ
statement.
.exam begin
    READ( UNIT=*, FMT=*, END=100 ) X, Y
    .
    .
    .
100    code to handle "End of File"
.exam end
.np
End of file may also be handled by using the
.kw IOSTAT=
specifier
of the FORTRAN
.kw READ
statement.
.exam begin
READ( UNIT=*, FMT=*, IOSTAT=IOS ) X, Y
IF( IOS .NE. 0 )THEN
.
.   code to handle "End of File"
.
ENDIF
.exam end
.*
.section Printer Device Support
.*
.np
.ix 'printer device'
.ix 'device' 'printer'
Output can be written to a printer by using a printer device name as
the file name.
A printer can be specified in a "SET" command or through
the
.kw FILE=
specifier of the FORTRAN
.kw OPEN
statement.
Several device names may be used:
.millust begin
:FNAME.prn:eFNAME. or :FNAME.lpt1:eFNAME.
:FNAME.lpt2:eFNAME.
:FNAME.lpt3:eFNAME.
.millust end
.np
The printer can be treated as a carriage control device.
This is requested by using the
.mono CARRIAGECONTROL='YES'
specifier of the FORTRAN
.kw OPEN
statement.
.exam begin
OPEN( UNIT=1, FILE=':FNAME.prn:eFNAME.', CARRIAGECONTROL='YES' )
.exam end
.np
Carriage control handling is described in the
section entitled :HDREF refid='fdospfa'..
.*
.section Serial Device Support
.*
.np
.ix 'serial device'
.ix 'device' 'serial'
Output can be written to a serial port by using a serial device name
as the file name.
A serial device can be specified in a "SET" command or
through the
.kw FILE=
specifier of the FORTRAN
.kw OPEN
statement.
Three device names may be used:
.millust begin
:FNAME.aux:eFNAME. or :FNAME.com1:eFNAME.
:FNAME.com2:eFNAME.
.millust end
.np
The serial device can be treated as a carriage control device.
This is requested by using the
.mono CARRIAGECONTROL='YES'
specifier of the FORTRAN
.kw OPEN
statement.
.exam begin
OPEN( UNIT=1, FILE=':FNAME.com1:eFNAME.', CARRIAGECONTROL='YES' )
.exam end
.np
Carriage control handling is described in the
section entitled :HDREF refid='fdospfa'..
.np
To set serial characteristics such as speed, parity, and word length,
the "MODE" command may be used.
.exam begin
C>mode com1:9600,n,8,1
.exam end
.pc
The above example sets serial port 1 to a speed of 9600 BAUD with no
parity, a word length of 8 and 1 stop bit.
.*
.section File Handling Defaults
.*
.np
.ix 'file defaults'
The following defaults apply to file specifications:
.begbull
.bull
.ix 'record type' 'default'
.ix 'defaults' 'record type'
The following table indicates the default
.us record type
for the allowable access methods and forms.
.millust begin
File                    Form
Access         Formatted   Unformatted
              +-----------+-----------+
Sequential    |   Text    | Variable  |
              +-----------+-----------+
Direct        |   Text    | Fixed     |
              +-----------+-----------+
.millust end
.pc
Unless the record type of the file does not correspond to the default
assumed by &cmpname, the record type attribute should not be
specified.
.bull
.ix 'record length' 'default'
.ix 'defaults' 'record length'
Unless otherwise stated, the default
.us record length
for a file is 1024 characters.
When access is "direct", the record length must be specified in the
.kw RECL=
specifier of the FORTRAN
.kw OPEN
statement.
The record length may also be specified when the access is
"sequential".
This should be done whenever access is "sequential" and the maximum
record length is greater than the default.
.bull
.ix 'record access' 'default'
.ix 'defaults' 'record access'
The default
.us record access
is "sequential".
.bull
.ix 'file name' 'default'
.ix 'defaults' 'file name'
When reading from or writing to a unit for which no preconnection has
been specified or no "FILE=" form of the FORTRAN
.kw OPEN
statement has been executed, the default
.us file name
takes the form:
.millust begin
FORnnn
.millust end
.pc
.us nnn
is a three-digit FORTRAN unit number.
Unit 0 is "000", unit 1 is "001", unit 2 is "002", and so on.
There is no file extension in this case.
.bull
If the connection between a unit number and a file is discontinued
through use of the FORTRAN
.kw CLOSE
statement, the same rule for constructing a file name will apply on
the next attempt to read from or write to the specified unit.
.endbull

⌨️ 快捷键说明

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