Microsoft KB Archive/32964

How COBOL 2.x Can Open More Than 15 Files at One Time

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

2.00 2.10 2.20 MS-DOS

Summary: It is possible to perform DOS Interrupt 21H, Function 67H, to increase the number of file handles you can open at once in a program running under DOS Version 3.3 or later. To take advantage of this feature in a COBOL Version 2.0, 2.1, or 2.2 program, you must write and call an assembly-language routine. The assembly-language code must be linked into RUNCOB.EXE, the COBOL Version 2.x run-time module.

More Information: The following demonstrates this procedure: 1. Operation under DOS Version 3.3 or greater is required. If the DOS SHARE.EXE command is in use, it is important to invoke SHARE/F:nnnnn to increase the area for file-sharing above the default of 2048 bytes. Please refer to your MS-DOS manual for more information about the SHARE utility. 2. Edit the CONFIG.SYS file to contain a FILES=x statement, where x is the number of file handles desired. Under DOS Version 3.3, x can be no greater than 255. Please note that if no CONFIG.SYS file is present, x defaults to 8. 3. Create an assembly routine that calls DOS Interrupt 21H, Function 67H. The routine must adhere to the assembly code examples in the “Microsoft COBOL Compiler for MS-DOS User’s Guide” (Pages 94-100) to be compatible with COBOL. Before calling the interrupt, register bx must contain the number of file handles desired (referred to as x above). The following example allows you to open up to 250 files at once (memory depending) in a COBOL program: TITLE MOREFILE include userseg.mac START_CSEG MOREFILE mov bx,255 ;make max file handles available mov ah,67H ;the function to be called INT 21H ;call interrupt ret END_CSEG MOREFILE END 4. Edit the USERPROG.MAC file by adding one line specifying the name of the assembly-language routine. USERPROG.MAC is the assembly-language interface table include file used by COBOL to extend run-time support. For example, if the name of the routine is MOREFILE, add the following line: asmnam MOREFILE,asm86 5. Run the MAKERUN.BAT file to construct the new run-time module containing your new assembly routine. The correct syntax is as follows: MAKERUN NameOfRunTime NameOfAssemblyRoutine 6. Install the run-time module created in Step 5, with the following command: INSTALL NameOfRunTime.EXE. 7. If the previous steps are executed successfully, COBOL programs will be able to open x files at once, after the assembly routine has been successfully CALLed. If the name of the assembly routine is MOREFILE, the syntax for calling MOREFILE from COBOL is the following: CALL “MOREFILE”. Please note that even when following the steps listed above and specifying FILES=255 in your DOS CONFIG.SYS file, it may not be possible to access 255 files at once in the COBOL program because there may not be enough memory available in the DGROUP data segment to allocate file buffers. Also note that five file handles are reserved by MS-DOS and COBOL.

Additional reference words: 2.00 2.10 2.20 Copyright Microsoft Corporation 1993.