Problem:
Some directives that configure how files are dealt with, their internal format , for example FDCLEAR & IDXFORMAT, can be especified in any part of the source code.
This article will set out the procedures to set those directives only for a particular file, as supposed to all the files in the program.
Resolution:
There are quite a few compiler directives that configure the behavior of the file handler. A few of them can only be set at the begining of the program (or outside, in cobol.dir or in the Net Express project...) and its settings will affect all the files defined in your program.
But quite a few of them can be set/unset in any part of the program and this feature allows us to configure different behavior for each file defined in our COBOL program. You know that this is possible because when you access the online help for that directive (Contents / Reference / Compiler Directives ) you will see in the description for that directive something like:
Properties:
Default: ...........
Phase: ...........
$SET: Any
There are quite a few directives that affect the file handler behavior and can be set in this way, some of them are:
ASSIGN - Default filename assignment
DATACOMPRESS - Data compression
FDCLEAR - Clear record buffers
FILETYPE - Data file format
IDXFORMAT - Indexed file structure
IXNLSKEY - Local collating sequence for sorting index file keys
IXNUMKEY - True numeric sorting on index keys
KEYCHECK - Check keys are defined
KEYCOMPRESS - Key compression
RETRYLOCK - Retry reads on locked records
WRITETHROUGH Unbuffered writes
Let's see an example with the FDCLEAR compiler directive where we define 3 different files, file-1, file-2 and file-3 but we only apply the FDCLEAR directive to file-2, so only the record buffer for file-2 will be cleared after a WRITE operation:
file-control.
select file-1 ...
$set fdclear
select file-2 ...
$set nofdclear
select file-3 ...
In this particular example the file handler won't clear the record buffer for file-1 after a WRITE operation if FDCLEAR hasn't been set earlier on in the source or outside in cobol.dir or in the project, as the default setting for FDCLEAR is NOFDCLEAR.
Some dialets like VSC24 set other directives, for example FDCLEAR, so in the above example to make sure that the record buffer for file-1 is not cleared the following could have been defined:
$set nofdclear
file-control.
select file-1 ...
$set fdclear
select file-2 ...
$set nofdclear
select file-3 ...
