COBOL Manual for TNS and TNS/R Programs

Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
28-42
Determining Whether Two COBOL File Names
Specify the Same Physical File
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:
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.
Value
Returned Meaning
-1 The two internal file names do not refer to the same physical file.
0 The two internal file names refer to the same physical file.
1 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).