Microsoft KB Archive/59726

DELETE FILE Gives Error 255 for Missing ISAM Files

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

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

Summary: When using the DELETE FILE statement, if the file to be deleted doesn’t exist, two different run-time errors are generated (depending on the ORGANIZATION of the file). If the ORGANIZATION is not INDEXED (that is, SEQUENTIAL, LINE SEQUENTIAL, or RELATIVE), the correct error message, run-time error 13, is generated. However, if the ORGANIZATION is INDEXED, the error generated is 255. Error 255 is not documented in the “Microsoft COBOL Compiler 3.0: Error Messages Manual” and stands for “undefined error.” 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: The DELETE FILE command is used in COBOL to delete files from a disk. The syntax is as follows: DELETE FILE {file-name}… Here “{file-name}…” is a list of data-names that contain the names of the files to delete. If a file to be deleted does not exist on the disk, run-time error 13 (File not found) should be generated. However, if the file that doesn’t exist has been described in the SELECT clause as having INDEXED organization, run-time error 255 (undefined error) is generated. If a FILE STATUS is defined for the file, it reports the same error (that is, status key 1 will be 9 and status key 2 will be 255). This problem occurs both in DOS (real mode) and OS/2 (protected mode) programs. The program example (DELETE.CBL) below illustrates how to use the DELETE FILE statement. To compile and link the program for DOS mode, enter the following commands: cobol delete; link delete ixsio; To compile and link the program for OS/2 mode, enter the following commands: pcobol delete; link /nop delete ixsio,,,lcobol doscalls;

Code Example
ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT ISAM-FILE ASSIGN TO &quot;ISAM.DAT&quot; ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL RECORD KEY IS ISAM-RECORD. SELECT REL-FILE ASSIGN TO &quot;REL.DAT&quot; ORGANIZATION IS RELATIVE. SELECT SEQ-FILE ASSIGN TO &quot;SEQ.DAT&quot; ORGANIZATION IS SEQUENTIAL. SELECT LINE-FILE ASSIGN TO &quot;LINE.DAT&quot; ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD ISAM-FILE. 01 ISAM-RECORD  PIC X.   FD REL-FILE. 01 REL-RECORD   PIC X.   FD SEQ-FILE. 01 SEQ-RECORD   PIC X.   FD LINE-FILE. 01 LINE-RECORD  PIC X.   PROCEDURE DIVISION. *   If the following file doesn't exist, *   run-time error 255 will be generated: DELETE FILE ISAM-FILE. *   If any of the following files don't exist, *   run-time error 13 will be generated: DELETE FILE REL-FILE, SEQ-FILE, LINE-FILE. STOP RUN. Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.