Microsoft KB Archive/21135

COBOL 2.x Write to COM1: Can Hang Unless MODE Set; Can’t Read

PSS ID Number: Q21135 Article last modified on 11-16-1992

2.00 2.10 2.20 MS-DOS

Summary: Writing to the COM1 device can sometimes hang the computer at run time from a COBOL Version 2.00, 2.10, or 2.20 program for MS-DOS if the serial communications parameters (baud, parity, stop bits, start bits, etc.) are set improperly in MS-DOS. COBOL 2.x programs do not have the ability to set these parameters. To work around this problem, use the MS-DOS MODE command to set the COM1 port with the proper parameters (baud, parity, etc.) before running the COBOL program that outputs to the port. Please note that it is not possible to reliably read from the communications port with Microsoft COBOL Version 2.00, 2.10, or 2.20, but it is possible to write to the communications port. COBOL does not perform any handshaking when reading or writing from or to COM1, so data can be lost when reading. Writing can be done to COM1 from a COBOL program as long as the receiving (non-COBOL) program can keep up with the speed that the COBOL program writes out the data.

Documentation Correction
This information needs to be added to Section 7.3, “Using MS-DOS and Nondisk Files,” on Page 54 of “Microsoft COBOL Compiler for MS-DOS: User’s Guide” for Versions 2.00, 2.10, and 2.20. This section fails to describe the lack of handshaking when you attempt to read from AUX or COM1:. COBOL 2.x programs are not suitable for reading reliably from COM1: or AUX.

Copyright Microsoft Corporation 1992.