Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
CLOSE
◄Up► ◄Contents► ◄Index► ◄Back►
─────CLOSE──────────────────────────────────────────────────────────────────
Action
Disconnects a specified unit.
Syntax
CLOSE ([UNIT=]unitspec
[, ERR=errlabel]
[, IOSTAT=iocheck]
[, STATUS=status])
If UNIT= is omitted, unitspec must be the first parameter. The
parameters can otherwise appear in any order.
Parameter Description
unitspec An integer expression specifying an external
unit.
errlabel The label of an executable statement in the
same program unit. An I/O error causes transfer
of control to the statement at <errlabel>. If
<errlabel> is omitted, the effect of an I/O
error is determined by the presence or absence
of <iocheck>.
iocheck An integer variable that returns zero if there
is no error, or the error number if an error
occurs.
status File status, either 'KEEP' or 'DELETE'.
Remarks
Files opened without a file name are scratch files. For such
files the default <status> is 'DELETE'. Specifying STATUS='KEEP'
for scratch files causes a run-time error. The default for
<status> for all other files is 'KEEP'.
Any files still open at program termination are automatically
closed according to their default status.
Closing unit 0 automatically reconnects unit 0 to the keyboard
and screen. Closing units 5 and 6 automatically reconnects those
units to the keyboard or screen, respectively. Closing the
asterisk (*) unit causes a compile-time error.
If a parameter of the CLOSE statement is an expression that calls
a function, that function must not cause an I/O operation or the
EOF intrinsic function. If these functions are called, the
results are unpredictable.
For QuickWin applications, STATUS='KEEP' causes the child window
associated with the unit to remain open until the user closes the
window or terminates the application.
Example
C Close and discard file:
CLOSE (7, STATUS = 'DELETE')
-♦-