Passing file handles to subroutines

In HP COBOL compatibility mode, you can pass the operating system's file handle for an open COBOL file to a subroutine by referring to that file's SELECT name in the CALL statement. One reason for doing this is to call an operating system function that allows the file to retrieve information not available through COBOL. For example:

ENVIRONMENT DIVISION.
FILE-CONTROL.
SELECT MY-FILE
ASSIGN TO DISK
SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD MY-FILE.
01 RECORD-1     PIC X(80).

PROCEDURE DIVISION.
MAIN-LOGIC.
   OPEN INPUT MY-FILE.
   CALL "SUB" USING MY-FILE.
   CLOSE MY-FILE.

These rules apply when passing file handles to subroutines: