Microsoft KB Archive/35721

From BetaArchive Wiki

How to Invoke "_MSRENAME" COBOL 3.0 Extension Subroutine

PSS ID Number: Q35721 Article last modified on 04-20-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 "_MSRENAME" replaces the extension “RENAME” found in earlier Microsoft COBOL 2.x Versions. This extension subroutine may be called from a COBOL program to change a disk filename to a different name. The syntax for this command given in MS2-2.DOC (found on the Setup disk) will cause the compiler to issue the following error message: Call parameter is literal (or LENGTH of) By content assumed Despite this warning message, the generated code may be used successfully. The sample program below works correctly and generates no error messages when compiled with the ANS85 directive.

More Information: In the example below, the name of the file to be renamed must be assigned to the variable Old-File, and the new name must be assigned to the variable New-File. If the file is not located in the default directory, the names must include the path. The value returned in the variable My-Status will be “00” if the procedure was successful or “92” if a duplicate name was found and no action was take or “30” unsuccessful Old-FIle not found. The following is a code example: DATA DIVISION. WORKING-STORAGE SECTION. 01 OLD-FILE PIC X(80) VALUE “C:.DAT”. 01 NEW-FILE PIC X(80) VALUE “C:.DAT”. 01 MY-STATUS PIC XX. PROCEDURE DIVISION. MAIN. CALL "_MSRENAME" USING BY REFERENCE OLD-FILE, BY CONTENT LENGTH OF OLD-FILE, BY REFERENCE NEW-FILE, BY CONTENT LENGTH OF NEW-FILE, BY REFERENCE MY-STATUS. DISPLAY “SUCCESS STATUS WAS” MY-STATUS. STOP RUN.

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.