COBOL Manual for TNS and TNS/R Programs

Libraries and Utility Routines
HP COBOL Manual for TNS and TNS/R Programs522555-006
13-88
COBOLASSIGN
A CLOSE LOCK on a file using a dynamic fd-name closes the file but does not lock
it. If locking were allowed, it would only prevent the reuse of the fd-name for the
remainder of the run unit’s existence; the file would still be accessible through another
dynamic fd-name.
A command interpreter ASSIGN command cannot designate an fd-name as
dynamically assignable—you must do this in the source program. ASSIGN can,
however, assign a default value to the previously designated dynamic file name. The
effect is the same as having an ENTER COBOLASSIGN statement as the first
statement in the program. See ASSIGN Command.
A CRE HP COBOL program can call either COBOLASSIGN (the COBOL-environment
routine) or COBOL_ASSIGN_ (the equivalent CRE routine). If it calls COBOLASSIGN,
it actually calls COBOL_ASSIGN_ indirectly. There are advantages to calling
COBOL_ASSIGN_ directly (see COBOL_ASSIGN_).
Example 13-16. COBOLASSIGN Routine
IDENTIFICATION DIVISION.
...
ENVIRONMENT DIVISION.
...
SPECIAL-NAMES.
FILE "$SYSTEM.SYSTEM.COBOLLIB" IS COBOLLIB.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PARTNO ASSIGN #DYNAMIC.
DATA DIVISION.
...
WORKING-STORAGE SECTION.
01 PART-FILE-NAME PICTURE X(35).
01 ASSIGN-ERROR COMP PICTURE 9999.
PROCEDURE DIVISION.
SETUP.
DISPLAY "ENTER CHOSEN PART FILE NAME"
ACCEPT PART-FILE-NAME
ENTER "COBOLASSIGN" OF COBOLLIB USING PARTNO
PART-FILE-NAME
GIVING ASSIGN-ERROR
IF ASSIGN-ERROR = 0
OPEN INPUT PARTNO
ELSE IF ASSIGN-ERROR = 1
...