Microsoft KB Archive/59320

Nested Programs Using Same EXTERNAL File Don’t DISPLAY SCREEN

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

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

Summary: If a COBOL source file contains a nested program and both programs declare the same file as EXTERNAL, after the nested program is called, it will not be able to DISPLAY any screens defined in its SCREEN SECTION. Also, the next DISPLAY of a screen in the calling program may be preceded and succeeded by a screen blank. Microsoft has confirmed this to be a problem in 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: Versions 3.0 and 3.0a of the compiler allow for nested COBOL programs by using the NESTCALL and ANS85 directives. The structure of a nested program is as follows: $SET NESTCALL $SET ANS85 IDENTIFICATION DIVISION. PROGRAM-ID. PROG-1. PROCEDURE DIVISION. . CALL PROG-2. . STOP RUN. IDENTIFICATION DIVISION. PROGRAM-ID. PROG-2. . . . EXIT PROGRAM. END PROGRAM PROG-2. END PROGRAM PROG-1. The nested program (PROG-2) is accessed with the CALL statement. However, there is a problem using nested programs when the calling and called programs declare the same file as EXTERNAL. In this situation, any DISPLAYs of screens in the called program fail, and the next DISPLAY of a screen in the calling module may be preceded and followed by a screen blank. The example program at the end of this article demonstrates this problem, but other problems may exist and may influence what types of data items or screens are displayed and it what order. Any change to the screen definition in the calling program may make its display work correctly. For example, if a LINE clause is added to the screen definition in PROG-1, the screen blanking does not occur, but the calling module is still unable to display any screens. Changing the directives used for compilation may also affect the display. In the following example source file, PROG-1 is the main program and it CALLs PROG-2, a nested program. The programs declare the same file as EXTERNAL. The screen DISPLAY in PROG-2 fails and the screen DISPLAY in PROG-1 (which is after the CALL) performs a screen blank before and after the display, leaving just the DOS prompt on the screen after execution. Removing the IS EXTERNAL clause from either FD (file description) makes the program execute correctly. $SET NESTCALL $SET ANS85 ''This is the calling program. IDENTIFICATION DIVISION. PROGRAM-ID. PROG-1. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. ''This is the EXTERNAL file. SELECT a-file ASSIGN TO “FILE.DAT”. DATA DIVISION. FILE SECTION. FD a-file IS EXTERNAL. 01 a-record PIC X. SCREEN SECTION. ''This screen will be blanked before and after its display. 01 screen-1. 05 “screen-1”. PROCEDURE DIVISION. CALL “PROG-2”. CANCEL “PROG-2”. DISPLAY screen-1. STOP RUN. ''This is the nested, called program. IDENTIFICATION DIVISION. PROGRAM-ID. PROG-2. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. ''This is the EXTERNAL file again. FILE-CONTROL. SELECT a-file ASSIGN TO “FILE.DAT”. DATA DIVISION. FILE SECTION. FD a-file IS EXTERNAL. 01 a-record PIC X. SCREEN SECTION. ''This screen will not display at all. 01 screen-2. 05 “screen-2”. PROCEDURE DIVISION. DISPLAY screen-2. EXIT PROGRAM. END PROGRAM PROG-2. END PROGRAM PROG-1.

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