Microsoft KB Archive/37338

An Underscore in the Program-ID Causes COBOL Compiler to Hang

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

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

Summary: If the name specified in the PROGRAM-ID begins with an underscore and is not surrounded by double quotation marks, the compiler issues two error messages and then hangs, requiring a CTRL+BREAK to abort. The two error messages are as follows: 4-S “Illegal character” 14-E “Period missing. Period assumed.” Microsoft has confirmed this to be a problem in Microsoft COBOL Compiler versions 3.0 and 3.0a. This problem was corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2. To work around the problem, put the program name in the PROGRAM-ID inside double-quotation marks.

More Information: For interlanguage calling with C, if C calls a COBOL 3.0 or 3.0a routine, you must use an underscore in the PROGRAM-ID in order to force an underscore into the name in the .OBJ file. Note that the underscore character in the PROGRAM-ID is not allowed in Microsoft COBOL Compiler versions 2.0, 2.1, 2.2, and earlier. To reproduce the problem, compile the sample program below with the following command line and accept the standard default directives: COBOL progname;

Code Example
IDENTIFICATION DIVISION. PROGRAM-ID. _cobsub. * To work around the problem, use: PROGRAM-ID. &quot;_cobsub&quot;. ENVIRONMENT DIVISION. DATA DIVISION. LINKAGE SECTION. 01 DUMMY            PIC 9(4) COMP-5. PROCEDURE DIVISION USING DUMMY. DISPLAY DUMMY. DISPLAY &quot; GREETINGS FROM THE COBOL SUBROUTINE &quot;. EXIT PROGRAM. Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.