COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Many Enscribe routines require file numbers instead of file names. Each of these routines returns
a file number:
HP COBOL routine COBOLFILEINFO or COBOL_FILE_INFO_
Enscribe routine FILE_GETINFO_
Each of the preceding routines can return other file attributes in addition to the file number; use
the routine best suited to your needs.
The HP COBOL routine COBOLFILEINFO or COBOL_FILE_INFO_ accepts a COBOL file name and
returns:
The file number of the file
The internal form of the file name associated with the file description
The file-system error code of the last input-output operation attempted for that file
For more information about the COBOLFILEINFO routine, see COBOLFILEINFO. For more information
about the COBOL_FILE_INFO_ routine, see COBOL_FILE_INFO_.
The FILE_GETINFO_ procedure can return more attributes than the HP COBOL routine
COBOLFILEINFO can. For details, see the Guardian Procedure Calls Reference Manual.
Determining Whether Two COBOL File Names Specify the Same Physical File
Through programmer error or a TACL ASSIGN command, two COBOL file names in the same run
unit can refer to the same physical file. This situation is not forbidden; in fact, it can be useful: you
can develop a server by having the input come from a disk file and the output go to a printer, and
then putting the server into production with both the input file and the output file assigned to
$RECEIVE.
Having two COBOL file names refer to the same physical file can also cause problems. If, for
example, a program has two output files that are intended as two separate reports, and both are
assigned to the same printer (not a spooler collector but the same mechanical device), then the
program terminates abnormally. If both files have the exclusion mode SHARED, the lines of the
two reports are interspersed on the paper.
To enable your HP COBOL program to detect that two of its HP COBOL file names refer to the
same external file, call operating system routine FILENAME_COMPARE_. FILENAME_COMPARE_
accepts two file names in internal form and returns a numeric value:
MeaningValue Returned
The two internal file names do not refer to the same physical file.-1
The two internal file names refer to the same physical file.0
The two internal file names refer to the same volume name, device name, or process
name, but the remainder of the two file names do not match (such as two instances of
the same spooler collector that specify different locations).
1
A negative value other than -1 represents a file-system error number having the corresponding
positive value; for example, if at least one of the parameters specifies an illegal file name, the
value returned is -13.
For more information about the FILENAME_COMPARE_ routine, see the Guardian Procedure Calls
Reference Manual.
Purging a File From an HP COBOL Program
The HP COBOL language provides no mechanism for deleting a file from the system directory; an
HP COBOL program can purge a file only through an explicit call to the FILE_PURGE_ procedure.
The file being purged must be closed.
884 Disk Input and Output