📄 fdosfile.gml
字号:
8.30 7.10 15.40
8.20 3.50 11.70
.exam end
.np
.bd Exhibit 2:
.np
Suppose that we now wish to write the output from the above program to
a disk file instead of the screen.
We can do this without modifying the program.
Since we know that the
.kw WRITE
statement refers to unit 6, we can alter the default preconnection of
unit 6 to the screen by issuing another "SET" command.
.exam begin
C>set 6=numbers.rpt
C>iodemo
C>type numbers.rpt
1.40 2.50 3.90
3.90 8.70 12.60
1.10 9.90 11.00
8.30 7.10 15.40
8.20 3.50 11.70
.exam end
.pc
Now any time a program writes or prints to unit 6, the output will be
written to the disk file :FNAME.numbers.rpt:eFNAME..
If you are going to run other programs, it would be wise to remove the
connection between unit 6 and this file so that it is not accidentally
overwritten.
This can be done by issuing the following command.
.exam begin
C>set 6=
.exam end
.np
You should also do the same for unit 1.
.np
.bd Exhibit 3:
.np
Must we always use "SET" commands to establish the connection between
a unit and a file?
Suppose that you want to run the program quite often and that you do
not want to issue "SET" commands every time.
We can do this by modifying the program to include FORTRAN
.kw OPEN
statements.
.millust begin
* File ':FNAME.iodemo.for:eFNAME.'
OPEN( 1, FILE='NUMBERS.DAT' )
OPEN( 6, FILE='NUMBERS.RPT' )
10 READ( 1, *, END=99 ) X1, X2
WRITE( 6, 20 ) X1, X2, X1 + X2
GO TO 10
20 FORMAT( 3F6.2 )
99 END
.millust end
.pc
This is an example of a connection that is established at execution
time.
The connection that is established by the
.kw OPEN
statement overrides any preconnection that we might have established
using a "SET" command.
We say that the
.kw OPEN
statement has a higher precedence.
However, even the
.kw OPEN
statement does not have the final word on which files will be
accessed.
You may wish to read the next section on the &cmpname run-time system
logical file name support to find out why this is so.
.*
.section Logical File Name Support
.*
.np
.ix 'logical file name'
.ix 'SET command'
The &cmpname run-time system supports logical or symbolic file names
using the "SET" command.
The "SET" command may be used to define a logical file name and its
corresponding actual file name.
The format for defining a logical file name is as follows:
.millust begin
SET name=file_spec
.millust end
.synote
.note name
is any character string.
The letters in "name" may be specified in upper or lower case.
Lower case letters are treated as if they had been specified in upper
case.
Thus "SYSINPUT" and "sysinput" are equivalent.
Note, however, that blank characters must not be specified before and
after the "=" character.
.note file_spec
is the file specification of logical file.
.endnote
.autonote Notes and Examples:
.note
A logical file name may be used in the
.kw FILE=
specifier of the FORTRAN
.kw OPEN
and
.kw INQUIRE
statements.
.exam begin
* File ':FNAME.iodemo.for:eFNAME.'
OPEN( 1, FILE='SYSINPUT' )
10 READ( 1, *, END=99 ) X1, X2
WRITE( 6, 20 ) X1, X2, X1 + X2
GO TO 10
20 FORMAT( 3F6.2 )
99 END
.exam end
.np
In the following example, we define the logical file name "SYSINPUT"
to correspond to the file :FNAME.numbers.dat:eFNAME..
.exam begin
C>set sysinput=numbers.dat
C>iodemo
1.40 2.50 3.90
3.90 8.70 12.60
1.10 9.90 11.00
8.30 7.10 15.40
8.20 3.50 11.70
.exam end
.note
If the name in a
.kw FILE=
specifier is not included in one of the environment variable names
then it is assumed to be the actual name of a file.
.exam begin
OPEN( 2, FILE='SYSOUT' )
.exam end
.ix 'logical file name' 'extended file names'
.note
The logical file name feature can also be used to provide additional
information regarding the file name at execution time.
.exam begin
* File ':FNAME.iodemo.for:eFNAME.'
OPEN( 1, FILE=':FNAME.numbers.dat:eFNAME.' )
10 READ( 1, *, END=99 ) X1, X2
WRITE( 6, 20 ) X1, X2, X1 + X2
GO TO 10
20 FORMAT( 3F6.2 )
99 END
.exam end
.pc
In the following example, the actual location (and name) of the file
:FNAME.numbers.dat:eFNAME. is described through the use of an environment
variable.
.exam begin
C>set numbers.dat=&dr2.&pc.data&pc.input.dat
C>iodemo
.exam end
.pc
As you can see, a logical file name can resemble an actual
file name.
.np
Of course, the entire file name could have been specified in the
FORTRAN program.
.exam begin
OPEN( 1, FILE=':FNAME.&dr2.&pc.data&pc.input.dat:eFNAME.' )
.exam end
.note
Only one level of lookup is performed.
.exam begin
* File ':FNAME.iodemo.for:eFNAME.'
OPEN( 1, FILE=':FNAME.sysinput:eFNAME.' )
10 READ( 1, *, END=99 ) X1, X2
WRITE( 6, 20 ) X1, X2, X1 + X2
GO TO 10
20 FORMAT( 3F6.2 )
99 END
.exam end
.np
This is illustrated by the following commands.
.exam begin
C>set sysinput=datafile
C>set datafile=input.dat
C>iodemo
.exam end
.pc
In the above example, unit 1 is connected to the file :FNAME.datafile:eFNAME.
and not the file :FNAME.input.dat:eFNAME..
.ix 'logical file name' 'device remapping'
.note
Logical file names can be used to direct output normally intended for
one device to another device.
Consider the following examples.
.exam begin
C>set lpt1=lpt2
.exam end
.pc
If the FORTRAN program specifies the name "LPT1" in an
.kw OPEN
or
.kw INQUIRE
statement, the &cmpname run-time system will map this name to "LPT2".
In an
.kw INQUIRE
statement, the
.kw NAME=
specifier will return the name "LPT2".
.note
As we mentioned earlier, the case of the name does not matter.
Upper or lower case can be used interchangeably.
.exam begin
C>set sysinput=&dr2.&pc.data&pc.input.dat
C>set SYSINPUT=&dr2.&pc.data&pc.input.dat
.exam end
.note
No spaces should be placed before or after the "=" in the "SET"
command.
The following two examples are considered quite
distinct from each other:
.exam begin
C>set sysinput=testbed.dat
C>set sysinput = testbed.dat
.exam end
.pc
This example will define two variables, "SYSINPUT" and
"SYSINPUT~b".
.note
An environment variable will remain in effect until you explicitly
remove it or you turn off the personal computer.
To remove an environment variable from the list, reenter the "SET"
command specifying everything up to and including the "=" character.
For example, to remove the definition for "SYSINPUT", the following
command can be issued.
.exam begin
C>set sysinput=
.exam end
.note
.ix 'logical file name' 'display'
Any time you wish to see the current list of environment strings,
simply enter the "SET" command with no arguments.
.exam begin
C>set
PROMPT=$d $t $p$_$n$g
COMSPEC=d:\dos\command.com
PATH=G:\;E:\CMDS;C:&pathnamup\BIN;D:\DOS;D:\BIN
&libvarup.=c:&pathnam.&libdir16.\dos
1=input.dat
2=output.dat
3=&dr4.&pc.database&pc.customer.fil
SYSINPUT=&dr2.&pc.data&pc.input.dat
LPT1=lpt2
.exam end
.endnote
:cmt. JBS.*
:cmt. JBS.section Open Files in the Run-time Environment
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'open files'
:cmt. JBS.ix 'files' 'open'
:cmt. JBSUnder &machsys, a number of files are open during the
:cmt. JBSexecution of your program.
:cmt. JBSThe following describes how the &cmpname run-time system makes use of
:cmt. JBSstandard &machsys files and describes those files which are opened by
:cmt. JBSyour program.
:cmt. JBSThis information may be used to determine how many files are actually
:cmt. JBSopen during the execution of your program.
:cmt. JBS.beglevel
:cmt. JBS.*
:cmt. JBS.section Standard Input
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'standard input'
:cmt. JBS.ix 'DOS' 'standard input'
:cmt. JBS.ix 'OS/2' 'standard input'
:cmt. JBS.ix 'CTTY'
:cmt. JBS.ix 'DOS' 'CTTY'
:cmt. JBSThe "Standard Input" file (handle 0) is permanently opened by &machsys
:cmt. JBSwhen the PC is started up.
:cmt. JBSNormally, standard input records are entered at the console keyboard.
:cmt. JBSStandard input may be redirected to another device using the DOS
:cmt. JBS"CTTY" command or to a file through the use of the "<" character on
:cmt. JBSthe program command line (see next section).
:cmt. JBSDuring program execution, unit 5 is preconnected to this file.
:cmt. JBS.*
:cmt. JBS.section Standard Input Redirection
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'standard input' 'redirection'
:cmt. JBSAnother file is opened by &machsys if standard input redirection ("<")
:cmt. JBSwas specified on the program command line.
:cmt. JBSDuring program execution, the specified file will be preconnected to
:cmt. JBSunit 5.
:cmt. JBS.*
:cmt. JBS.section Standard Output
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'standard output'
:cmt. JBS.ix 'DOS' 'standard output'
:cmt. JBS.ix 'OS/2' 'standard output'
:cmt. JBS.ix 'CTTY'
:cmt. JBS.ix 'DOS' 'CTTY'
:cmt. JBSThe "Standard Output" file (handle 1) is permanently opened by
:cmt. JBS&machsys when the PC is started up.
:cmt. JBSNormally, standard output records are printed on the console screen.
:cmt. JBSStandard output may be redirected to another device using the DOS
:cmt. JBS"CTTY" command or to a file through the use of the ">" character on
:cmt. JBSthe program command line (see next section).
:cmt. JBSDuring program execution, unit 6 is preconnected to this file.
:cmt. JBS.*
:cmt. JBS.section Standard Output Redirection
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'standard output' 'redirection'
:cmt. JBSAnother file is opened by &machsys if standard output redirection
:cmt. JBS(">") was specified on the program command line.
:cmt. JBSDuring program execution, the specified file will be preconnected to
:cmt. JBSunit 6.
:cmt. JBS.*
:cmt. JBS.section Standard Error File
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'standard error'
:cmt. JBS.ix 'DOS' 'standard error'
:cmt. JBS.ix 'OS/2' 'standard error'
:cmt. JBSThe "Standard Error" file (handle 2) is used by the &cmpname run-time
:cmt. JBSsystem as a last resort for displaying messages.
:cmt. JBSThis may occur when, for example, a diskette becomes entirely full and
:cmt. JBSit is no longer possible for the run-time system to write a message to
:cmt. JBSthe diskette.
:cmt. JBSOutput to the standard error file is produced on the screen.
:cmt. JBSUnder DOS 2.x, the standard error file is not normally opened until
:cmt. JBSsome output is written to it.
:cmt. JBSUnder DOS 3.x or later, the standard error file is permanently open.
:cmt. JBSDuring program execution, this file is used by the &cmpname run-time
:cmt. JBSsystem to issue diagnostic messages.
:cmt. JBS.*
:cmt. JBS.section Standard Auxiliary Device
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'standard auxiliary'
:cmt. JBS.ix 'DOS' 'standard auxiliary'
:cmt. JBSUnder DOS 3.x or later, the "Standard Auxiliary" device (handle 3) is
:cmt. JBSpermanently open.
:cmt. JBSThe auxiliary device is the asynchronous communications adapter
:cmt. JBSor serial port.
:cmt. JBSThis file is not used by the &cmpname run-time system but must be
:cmt. JBSconsidered as an open file when determining how many files are
:cmt. JBSactually open during the execution of a FORTRAN program.
:cmt. JBS.*
:cmt. JBS.section Standard Printer Device
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'standard printer'
:cmt. JBS.ix 'DOS' 'standard printer'
:cmt. JBS.ix 'OS/2' 'standard printer'
:cmt. JBSUnder DOS, the "Standard Printer" device (handle 4) is available to
:cmt. JBSthe executing process.
:cmt. JBSThis file is not opened unless written to.
:cmt. JBSThis file is not used by the &cmpname run-time system but must be
:cmt. JBSconsidered when determining how many files can be opened during the
:cmt. JBSexecution of a FORTRAN program.
:cmt. JBS.* .*
:cmt. JBS.* .section Unit 5
:cmt. JBS.* .*
:cmt. JBS.* .np
:cmt. JBS.* .ix 'unit 5'
:cmt. JBS.* Unit 5 is opened by the &cmpname run-time system if any input/output
:cmt. JBS.* statement references this file.
:cmt. JBS.* .exam
:cmt. JBS.* READ *, X, Y
:cmt. JBS.* .eexam
:cmt. JBS.* .pc
:cmt. JBS.* As we described in an earlier section on preconnected files, this
:cmt. JBS.* file is normally connected to the terminal keyboard.
:cmt. JBS.* .*
:cmt. JBS.* .section Unit 6
:cmt. JBS.* .*
:cmt. JBS.* .np
:cmt. JBS.* .ix 'unit 6'
:cmt. JBS.* Unit 6 is opened by the &cmpname run-time system if any input/output
:cmt. JBS.* statement references this file.
:cmt. JBS.* .exam
:cmt. JBS.* PRINT *, 'Enter a number'
:cmt. JBS.* .eexam
:cmt. JBS.* .pc
:cmt. JBS.* As we described in an earlier section on preconnected files, this
:cmt. JBS.* file is normally connected to the terminal screen.
:cmt. JBS.*
:cmt. JBS.section Files Opened by a FORTRAN Program
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'open files'
:cmt. JBSOther files can be opened by the executing FORTRAN program.
:cmt. JBSA file handle is associated with every file opened by &machsys..
:cmt. JBS.*
:cmt. JBS.section DOS File Handle Considerations
:cmt. JBS.*
:cmt. JBS.np
:cmt. JBS.ix 'handle'
:cmt. JBS.ix 'DOS' 'handle'
:cmt. JBSDOS manages files through the use of handles.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -