Microsoft KB Archive/40040

CALL X“91” SET Command Temporarily Changes COBOL Environment

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

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

Summary: MS-DOS environment variables that are SET in a Microsoft COBOL Version 3.0 or 3.0a program are not permanent. When a variable is SET while a program is running, COBOL only uses a copy of the environment string table that was in existence when the program is started. Any changes to this table are discarded when the program has terminated.

More Information: The following method can be used to execute an MS-DOS SET command, or any other MS-DOS command, .BAT file, .COM, or .EXE file from COBOL Versions 3.0 and 3.0a. CALL the subprogram X“91” using function 35. This function uses two parameters. When the first parameter is set to zero, this function executes any statement that was previously written to the command line buffer. This function is described in the “Microsoft COBOL Version 3.0: Operating Guide” on Pages 8-9 and 8-13. Make a batch file, SETBAT.BAT, with the following two entries: SET ABCD=ABCD SET This example will set a temporary entry in the string table and display it. However, when the program terminates, typing SET at the DOS prompt will show that the entry has been deleted. Compile and LINK COBPROG.COB below, accepting the default compiler directives. * COBPROG.COB $set ANS85 working-storage section. 01 result pic 99 comp-x. 01 function pic 99 comp-x value 35. 01 parameters. 05 param1 pic 99 comp-x value 0. 05 param2 pic xx value spaces. PROCEDURE DIVISION. * Put the desired command in the command line buffer. DISPLAY “setbat.bat” UPON COMMAND-LINE. * Call the subprogram to execute the command. CALL X“91” USING result, function, parameters. STOP RUN.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.