Microsoft KB Archive/50465

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Can’t Reference EXTERNAL File After CALL to ENTRY Point; Hangs

PSS ID Number: Q50465 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, versions 3.0 and 3.0a

Summary: An attempt to reference an EXTERNAL FILE from within a program CALLed using an ENTRY POINT will cause one of the following symptoms: 1. A machine hang 2. A “protection violation” under MS OS/2 3. Run-time error 166 “Recursive COBOL call illegal” and/or run-time error 161 “Illegal intermediate code” 4. Display of run-time error 203 “Call parameter not supplied” when run in the ANIMATOR, even though there are no parameters missing A program CALLed at an ENTRY point can reference files that are not EXTERNAL. Microsoft has confirmed this to be a problem with Microsoft COBOL Compiler versions 3.0 and 3.0a for MS-DOS and MS OS/2. This problem has been corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2.

More Information: This error occurs whether the FILE-ID is hard coded into the program or assigned to a WORKING STORAGE DATA-NAME. This error is not dependent on how EXTFH and EXTERNL are linked to the code, and it happens regardless of the DIRECTIVES set. FILES referenced from a CALLed program work correctly. To work around the problem, do not use an ENTRY point. Instead, make a CALL to the second program using its PROGRAM-ID or its disk name. Then, pass a parameter stating where to begin the program. The parameter could be used to state where to GO TO in the second program. For a more structured approach, the parameter could be used to indicate which PARAGRAPH should be performed.

Code Example

The following program demonstrates the problem: Program 1: $SET NOLITLINK ERRQ *************************** * PROG1.COB ************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EXT-FILE ASSIGN TO DISK ORGANIZATION IS LINE SEQUENTIAL ACCESS MODE IS SEQUENTIAL. DATA DIVISION. FILE SECTION. FD EXT-FILE IS EXTERNAL VALUE OF FILE-ID IS FILE-NAME. 01 EXT-FILE-REC PIC X(80). WORKING-STORAGE SECTION. 77 FILE-NAME PIC X(12) VALUE “TESTFILE.DAT”. PROCEDURE DIVISION. START-TEST. OPEN OUTPUT EXT-FILE. * make initial call so the entry point will be valid CALL “PROG2”. CALL “entry-pt”. CANCEL “PROG2”. CLOSE EXT-FILE. * NOW THE FILE CONTAINS “HELLO”. READ IT AND PRINT IT OUT. OPEN INPUT EXT-FILE. READ EXT-FILE. DISPLAY EXT-FILE-REC. CLOSE EXT-FILE. STOP RUN. Program 2: $SET NOLITLINK ERRQ *************************** * PROG2.COB ************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EXT-FILE ASSIGN TO DISK ORGANIZATION IS LINE SEQUENTIAL ACCESS MODE IS SEQUENTIAL. DATA DIVISION. FILE SECTION. FD EXT-FILE EXTERNAL VALUE OF FILE-ID IS “TESTFILE.DAT”. 01 EXT-FILE-REC PIC X(80). WORKING-STORAGE SECTION. 77 FILE-NAME PIC X(12) VALUE “TESTFILE.DAT”. PROCEDURE DIVISION. DISPLAY “IN PROG2”. GOBACK. ENTRY “entry-pt”. START-TEST. MOVE “HELLO” TO EXT-FILE-REC. WRITE EXT-FILE-REC. GOBACK. EXIT PROGRAM.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.