CLOSE Statement

The CLOSE statement is used to terminate the processing of a file or files, to change the current video-terminal window, or to close a floating window.

Format 1

CLOSE { file-name [REEL] [ WITH {NO REWIND} ] } ...
                  [UNIT]        {LOCK     }

Format 2

CLOSE WINDOW window-handle [ WITH NO DISPLAY ]

Syntax Rules

  1. file-name must be the name of a file described in the Data Division. It may not be a sort file.
  2. If the REEL or UNIT option is used, then file-name must refer to a sequential file.
  3. window-handle can be either a PIC X(10) data item or a HANDLE data item. If used with a SUBWINDOW, window-handle must have been the object of a POP-UP AREA phrase in a DISPLAY statement.

Format 1 (CLOSE File) General Rules

  1. A file referred to by a CLOSE statement must be in the open state. After the execution of a successful CLOSE statement, each file-name is in the closed state. All record and file locks held by those files are released.
  2. Any FILE STATUS variables associated with the file-names are updated by the CLOSE verb.
  3. The NO REWIND option lets you hold a pipe open when closing its corresponding file. This allows you to gather multiple reports into a single job for the print spooler. To use NO REWIND in this way, create a configuration file entry as described in SPOOL_FILE in ACUCOBOL-GT Appendices.
  4. The LOCK option prevents the affected files from being opened again by this run unit in its current execution.
  5. If the UNIT or REEL option is specified, then the file remains open and the next reel of the multi-reel file is mounted. Since ACUCOBOL-GT does not directly support multi-reel files, specifying this option causes the CLOSE statement to have no effect other than to update the FILE STATUS variable.

Format 2 (CLOSE WINDOW) General Rules

  1. The CLOSE WINDOW verb is used to remove floating windows and subwindows.
  2. window-handle must be a handle returned by a DISPLAY FLOATING WINDOW statement, or the object of a POP-UP phrase of a DISPLAY WINDOW statement that executed in the current run unit. Furthermore, it cannot have been the object of a CLOSE WINDOW verb nor may it have been otherwise modified.
  3. The CLOSE WINDOW verb restores the contents of the screen covered by the window that is being destroyed. In other words, the window that was created by that DISPLAY FLOATING WINDOW or DISPLAY WINDOW statement is removed from the screen and replaced by the contents of the screen that was under that window. Any memory associated with the closed window is then freed.
  4. The window that was current when the terminating window was created becomes the active window. The cursor is positioned to the location it occupied when the window was created.
  5. The WITH NO DISPLAY option causes the closed window to remain on the screen. The effect is the same as a normal CLOSE WINDOW verb, except that no updating of the console takes place. This can be used to free memory used by a window when you do not want to physically remove it from the screen. For example, suppose you want to remove a series of nested windows and want to reduce the amount of screen activity that occurs. In this case, you can close all of the nested windows with the NO DISPLAY option and then close the outermost window in the normal manner.

    WITH NO DISPLAY is ignored when a floating window is closed. It is effective only when pop-up windows are closed.

  6. CLOSE WINDOW window-handle is synonymous with DESTROY window-handle.