Microsoft KB Archive/57929

From BetaArchive Wiki

CALL X“91” Bad Results on Later Calls Unless Parameters Reset

PSS ID Number: Q57929 Article last modified on 01-24-1990

3.00 3.00a MS-DOS

Summary: Using CALL X“91” to execute a DOS command or executable file does not execute properly on multiple executions if the variables are not reset before each call. It is imperative to always set the values used in CALL X routines before each call. This information applies to Microsoft COBOL Compiler Versions 3.00 and 3.00a for MS-DOS.

More Information: The following code example gives incorrect results on the second and third execution of the CALL X“91” statement. The results vary from executing normally to doing nothing or hanging the machine. This is because by not resetting the function parameters, the program executes a random DOS interrupt. If you remove the comments from the four MOVE lines, the program will execute each CALL correctly. WORKING-STORAGE SECTION. 01 RESULT PIC 99 COMP-X VALUE ZERO. 01 FUNCTION PIC 99 COMP-X VALUE 35. 01 PARAMETER. 03 LENGTH-1 PIC 99 COMP-X VALUE 3. 03 FILENAME PIC X(20) VALUE “DIR”. PROCEDURE DIVISION. PERFORM DIR-PARA 3 TIMES. STOP RUN. DIR-PARA. * MOVE ZERO TO RESULT. * MOVE 35 TO FUNCTION. * MOVE 3 TO LENGTH-1. * MOVE “DIR” TO FILENAME. CALL X“91” USING RESULT, FUNCTION, PARAMETER. DISPLAY “BACK FROM THE CALL X”91" FROM COBOL 3.00". DISPLAY RESULT.

Copyright Microsoft Corporation 1990.