Microsoft KB Archive/35515

From BetaArchive Wiki

How to Invoke "_MSEXIST" COBOL 3.0 Extension Subroutine

PSS ID Number: Q35515 Article last modified on 04-21-1993

3.00 | 3.00 MS-DOS | OS/2

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, version 3.0

Summary: The Microsoft COBOL Version 3.0 extension subroutine "_MSEXIST" replaces the extension “EXIST” found in earlier COBOL 2.x versions. This extension subroutine may be called from a COBOL program to check to see whether a specified file exists. The syntax for this call given in the file MS2-2.DOC (found on the Setup disk) will cause the MS COBOL Version 3.0 compiler to issue the following error message: Call parameter is literal (or LENGTH of) by content assumed Despite the warning message, the generated code may be used successfully. The following sample program works correctly and generates no error messages. The full name of the file must be assigned to the variable FILE-NAME. The returned value in MY-STATUS will be “00” if the file was present or “30” if the file does not exist. The code example is as follows: DATA DIVISION. WORKING-STORAGE SECTION. 01 MY-STATUS PIC 9(2). 01 FILE-NAME PIC x(80) VALUE “D:.DAT”. PROCEDURE DIVISION. MAIN. CALL "_MSEXIST" USING BY REFERENCE FILE-NAME, BY CONTENT LENGTH OF FILE-NAME, BY REFERENCE MY-STATUS. DISPLAY “FILE PRESENT” MY-STATUS. STOP-RUN.

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.