Examples of CLOSE Statements

In the following example, if FILEID is a temporary disk file, this statement closes the file and returns the disk space to the system.

CLOSE(FILEID)

The following example closes FILEID and, assuming FILEID is a tape file, positions the tape according to the description under CLOSE Options.

CLOSE(FILEID,*)

The following example closes, purges, and releases FILEID to the system. If FILEID is a permanent disk file, it is removed from the disk directory and the disk space is returned to the system. In the following example, assuming FILEID is a multireel tape file, the current reel is closed, and the next reel is opened.

CLOSE(FILEID,PURGE)
CLOSE(FILEID,REEL)

The following example closes FILEID and, assuming FILEID is a disk file, returns to the system the unused portion of the last row of FILEID.

CLOSE(FILEID,CRUNCH)

The following example requests an orderly close on subfile 1 of port file FILEID. Control is returned to the program as soon as the close has been checked for semantic consistency, because the DONTWAIT port close option is included.

CLOSE (FILEID [SUBFILE 1], CLOSEDISPOSITION = ORDERLY, DONTWAIT)

The following example requests a close of subfile 1 of port file FILEID. Since the <closedisposition option> is not specified, a CLOSEDISPOSITION ABORT operation is performed. Since the <control option> is not specified, WAIT is assumed, and control is not returned to the file until the close is complete. The information specified in the <associateddata option> is sent to the correspondent program during the close process. The length need not be specified because a string expression is being used.

CLOSE (FILEID [SUBFILE 1], ASSOCIATEDDATA = STRNG)

The following example requests a close of subfile 1 of port file FILEID. During the close process, 14 characters of data are taken, beginning at the location pointed to by PTR, and are sent to the correspondent process as associated data.

CLOSE (FILEID [SUBFILE 1], ASSOCIATEDDATALENGTH = 14,
       ASSOCIATEDDATA = PTR)