Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

CLOSE - Close file

The CLOSE macro closes files, i.e. it disconnects them from the user program in which they were opened. All input/output buffers which the system generated automatically when the file was opened are now released. The FCB is restored to the state it was in before the file was opened.

During CLOSE processing, the user program can make use of EXLST exits, as with OPEN processing, in order to position the tape (CLOSPOS) or write user labels (LABEND).

A CLOSE macro issued for a file which is not open is ignored.

Format

Operation

Operands

CLOSE

ALL / fcbadr / (1)

[,RWD / REPOS / DISCON / LEAVE / INVAL /
  KEEP-DATA-IN-CACHE / (0)]

[,PARMOD = 24 / 31]


Operand descriptions

fcbaddr

Address of the FCB for the file to be closed.

(0)

Register 0 contains the positioning key and CLOSE mode in the right-hand byte:

X'00'

LEAVE

X'01'

DISCON

X'02'

REPOS

X'03'

RWD

X'05'

INVAL (only with PARMOD=31)

X'06'

KEEP-DATA-IN-CACHE

(1)

Register 1 contains the FCB address.

ALL

Closes all files which were opened in the current program and have not yet been closed. System files and EAM files are not affected. If a file is not closed normally, a warning is issued.

DISCON

For tape files:
The tape is positioned to the start and unloaded/released. A device which may have been reserved using FILE remains assigned to the task; it is not released until a subsequent RELEASE command (REL macro) is issued.

INVAL

For disk files:
The cached pages of the file are to be invalidated, but not written back to the disk, i.e. the data is lost after CLOSE. INVAL can only be specified if PARMOD=31 applies.

KEEP-DATA-IN-CACHE

For disk files:
The data that was buffered in a cache is not saved to the disk at CLOSE. A subsequent OPEN on the same file can then use this data immediately.

Note

Files that have been closed in this way can be displayed using the SHOW-FILE-ATTRIBUTES command (CACHE-NOT-SAVED operand). A backup of the data from the cache onto the disk can be forced either by means of a further OPEN/CLOSE cycle without this function or implicitly when the cache is dissolved with the system administrator command STOP-PUBSET-CACHING or EXPORT-PUBSET. A file-specific cache backup for closed files is not possible.

LEAVE

For tape files:
The tape is positioned to the logical end of the file, depending on the LABEL specification in FILE or FCB.

If the BYPASS operand was specified in the FILE command, the tape position is not changed and the CLOSPOS routine is not activated. Otherwise the LEAVE functions are as indicated in the “REPOS” table: REPOS for OPEN≠REVERSE corresponds to LEAVE for OPEN=REVERSE, and vice versa.

In the case of LEAVE for OPEN OUTPUT, it should be noted that no CLOSPOS routine is activated, and the tape position is not changed.

For multifile tapes, the tape is rewound to the start by CLOSE unless LEAVE is specified.

PARMOD

Specifies the generation mode for the macro.

Default value:

the value predefined for the generation mode by means of the GPARMOD macro or preset by the assembler.

= 24
The macro is expanded in accordance with the format for the 24-bit interface. The object code is thus executable only in 24-bit addressing mode.

= 31
The macro is generated as addressing mode-independent.

REPOS

For tape files:
positions a tape to the logical beginning of the file, depending on the LABEL specification in FILE or FCB.

If the BYPASS operand was specified in the FILE macro, the tape is rewound and the CLOSPOS routine is not activated. In all other cases, the following table applies (position tape):

LABEL spec.

OPEN != REVERSE

OPEN = REVERSE

LABEL=(STD,n)

The tape is automatically positioned to HDR1;
FSEQ is not changed.

The tape is positioned to the tape mark after the last EOF label of the file;
FSEQ is incremented by 1.

LABEL=NSTD

                           

EXLST: CLOSPOS=NO,
the tape is automatically positioned to the start of tape mark;
FSEQ is not changed.

EXLST: CLOSPOS=NO,
the tape is positioned to the start of tape mark;
FSEQ=0

EXLST: CLOSPOS!=NO,
the user must program a routine to position the tape;
FSEQ is not changed

EXLST: CLOSPOS!=NO
the user himself positions the tape in the CLOSPOS routine;
FSEQ is not changed.

LABEL=NO


EXLST: CLOSPOS=NO,
the tape is automatically positioned to the tape mark after the last block;
FSEQ is incremented by 1.

For OPEN OUTPUT: no CLOSPOS routine, no positioning.

RWD

Default setting for tape files:
the tape is rewound and positioned to the start; FSEQ is set to zero (this also applies to files with NSTD labels), i.e. FSEQ points to the first file of the file set or tape volume.

Programming note

The CLOSE macro destroys the contents of registers 0, 1, 14 and 15.