Technical Notes Database
TN840D.txt FILE HANDLES EXTENDING
Category :Pascal
Platform :All
Product :Turbo Pascal 4.0+
Description:
Q. How do I open more than 15 files at one time?
A. In DOS version 3.3 and above there is a function call to allocate memory
for additional file handles. This will allow you to open more than 15
files at one time as long as your Files line in your CONFIG.SYS is 5
greater than the number of files you would like to open.
Here is an example program:
{$M $8000,0,$1000} { Important do not forget }
Program Many_Files;
Uses Dos;
Var
Files:array[1..30] of file;
I:Integer;
Procedure Allow_More_Files( Max_Files:Byte );
Var
Regs:Registers;
Begin
With Regs do
Begin
AH := $67;
BX := Max_Files;
Intr( $21,Regs );
If Flags And FCarry <> 0
Then
Writeln( 'Dos error : ',AX);
End;
End;
Begin
Allow_More_Files( 30 );
For I:=1 to 30 do
Begin
Assign(Files[I],'DAT.'+ Chr(I DIV 10+48) + Chr(I Mod 10+48));
Rewrite(Files[I]);
End;
For I:=1 to 100 do
Close( Files[I] );
End.
Reference:
7/16/98 4:35:36 PM
Last Modified: 01-SEP-99