Natural for OpenVMS Version 6.3.12 for OpenVMS
 —  Statements  —

CLOSE WORK FILE

CLOSE WORK [FILE]  work-file-number

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Related Statements: DEFINE WORK FILE | READ WORK FILE | WRITE WORK FILE

Belongs to Function Group: Control of Work Files / PC Files


Function

The statement CLOSE WORK FILE is used to close a specific work file. It allows you to explicitly specify in a program that a work file is to be closed.

A work file is closed automatically:

Top of page

Syntax Description

Syntax Element Description
work-file-number

The number of the work file (as defined to Natural) to be closed.

Top of page

Example

** Example 'CWFEX1': CLOSE WORK FILE                                    
************************************************************************
DEFINE DATA LOCAL                                                       
1 W-DAT   (A20)                                                         
1 REC-NUM (N3)                                                          
1 I       (P3)                                                          
END-DEFINE                                                              
*                                                                       
REPEAT                                                                  
  READ WORK FILE 1 ONCE W-DAT  /* READ MASTER RECORD                    
  /*                                                                    
  AT END OF FILE                                                        
    ESCAPE BOTTOM                                                       
  END-ENDFILE                                                           
  INPUT 'PROCESSING FILE' W-DAT (AD=O)                                  
      / 'ENTER RECORDNUMBER TO DISPLAY' REC-NUM                         
  IF REC-NUM = 0                                                        
    STOP                                                                
  END-IF
    FOR I = 1 TO REC-NUM                              
    /*                                              
    READ WORK FILE 1 ONCE W-DAT                     
    /*                                              
    AT END OF FILE                                  
      WRITE 'RECORD-NUMBER TOO HIGH, LAST RECORD IS'
      ESCAPE BOTTOM                                 
    END-ENDFILE                                     
  END-FOR                                           
  I := I - 1                                        
  WRITE 'RECORD' I ':' W-DAT                        
  /*                                                
  CLOSE WORK FILE 1                          
  /*                                                
END-REPEAT                                          
END                       

Top of page