Microsoft KB Archive/51598

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.

Error 137 “Illegal device … not mass storage”; COBOL 3.00

PSS ID Number: Q51598 Article last modified on 12-19-1989

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

Summary: The program shown below gives run-time error 137, which needs to be added to Chapter 4 of the “Microsoft COBOL Compiler 3.0: Error Messages Manual” for Versions 3.00 and 3.00a. This error means “Illegal device specification - not mass storage.” This information applies to Microsoft COBOL Versions 3.00 and 3.00a for MS-DOS and MS OS/2.

More Information: The following program, TEST.COB, when compiled and run produces run-time error 137. This error occurs because a file that is assigned to PRINTER is opened for I/O (I/O stands for input/output) and input cannot come from a PRINTER device. A file that is opened for I/O must be a mass storage device. Run-time error 137 is documented as follows in the “Micro Focus COBOL/2: Error Messages” manual, which was included with the Micro Focus product: 137 Open mode not supported for this file * You are trying to open a device in an illegal mode; for example, opening a printer for input. * Either the assignment of a file name is incorrect, or your program needs to be changed.

CodeExample

  $SET ANS85
   IDENTIFICATION DIVISION.
   PROGRAM-ID.  TestProgram.
  *
  * Example:  File status
  *
   ENVIRONMENT DIVISION.
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.
       SELECT TestFile
          ASSIGN TO DISK.
       SELECT Prt-File
          ASSIGN TO PRINTER.
   DATA DIVISION.
   FILE SECTION.
   FD   TestFile
     VALUE OF FILE-ID IS "MyInFile.dat".
   01   MyString        PIC X.
   FD Prt-File.
   01   Print-String    PIC X.
   PROCEDURE DIVISION.
   MyOpen.
          OPEN I-O TestFile Prt-File.
          CLOSE TestFile.
          CLOSE Prt-File.
          STOP RUN.

Compile and link as follows: COBOL TEST.COB; LINK TEST; If the program is compiled with the /ANIM compiler directive and executed in the animator, the error message “Illegal device specification - not mass storage” will be displayed. To correct this problem, break the OPEN statement into two statements, and open the PRINTER file for output only, as follows: OPEN I-O TestFile. OPEN OUTPUT Prt-File.

Copyright Microsoft Corporation 1989.