home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / PARADIS1 / FILES.PAS < prev    next >
Pascal/Delphi Source File  |  1991-01-29  |  4KB  |  107 lines

  1. (10407) Sun 26 Jan 92 15:56
  2. By: Ruurd Pels
  3. To: Kelly Small
  4. Re: Run-time Error 004
  5. St:
  6. ---------------------------------------------------------------------------
  7. @MSGID: 2:512/23 298326da
  8. @PID: XRS! 4.52
  9. Howdy Kelly!
  10.  
  11. On 21 Jan 92 10:39, Kelly Small, happily tapping away at his keyboard, wrote to
  12. Greg Belanger:
  13.  
  14.  KS> Regardless of what you have in your config.sys file, the most
  15.  KS> file handles a single program can have are 20, 5 of which are
  16.  KS> swiped by DOS, leaving you 15.
  17.  
  18. IMHO, they are swiped by TP6, and secondly, you can close them if you want to.
  19. Or am I wrong. BTW, there is a way around the 15 files max:
  20.  
  21. -+----8<--------8<--------8<--------8<--------8<--------8<--------8<------
  22. Offset $9  in the PSP is the standard File Handle Table (FHT).
  23. Offset $32 in the PSP is the size of the FHT.
  24. Offset $34 in the PSP is the address of the FHT.
  25.  
  26. By relocating the FHT to a space of your own you can open as much files as
  27. stated in the FILE= parameter in CONFIG.SYS.
  28.  
  29. const
  30.   MaxFiles                    = 30;
  31.  
  32. type
  33.   ParamRec                    = record
  34.                                   Len             : Byte;
  35.                                   List            : array[1..127] of Char;
  36.                                 end;
  37.   PSPType                     = record
  38.                                   Int32Inst       : Word;
  39.                                   TopOfDos        : Word;
  40.                                   Reserved1       : Byte;
  41.                                   DosDisp         : array[1..5] of Byte;
  42.                                   TerminateVec    : Pointer;
  43.                                   BreakVec        : Pointer;
  44.                                   ErrorVec        : Pointer;
  45.                                   ParentPSP       : Word;
  46.                                   FHArray         : array[1..20] of Byte;
  47.                                   EnvStrSeg       : Word;
  48.                                   DOSStackSave    : Pointer;
  49.                                   FHTSize         : Word;
  50.                                   FHTAddress      : Pointer;
  51.                                   Reserved2       : array[1..24] of Byte;
  52.                                   Int33           : array[1..3] of Byte;
  53.                                   Reserved3       : Word;
  54.                                   FCB1Ext         : array[1..7] of Byte;
  55.                                   FCB1            : array[1..9] of Byte;
  56.                                   FCB2Ext         : array[1..7] of Byte;
  57.                                   FCB2            : array[1..9] of Byte;
  58.                                   case Byte of
  59.                                     0: (Param: ParamRec);
  60.                                     1: (Dta  : array[1..128] of Byte);
  61.                                   end;
  62.                                 end;
  63. var
  64.   PSP                         : ^PSPType;
  65.   MyFHT                       : array[1..MaxFiles] of Byte;
  66.   OldFHTAddress               : Pointer;
  67.   OldFHTSize                  : Word;
  68.  
  69. procedure ExpandFHT;
  70.  
  71. begin
  72.   with PSP^ do begin
  73.     FillChar(MyFHT, SizeOf(MyFHT), 255);
  74.     OldFHTAddress := FHTAddress;
  75.     OldFHTSize    := FHTSize;
  76.  
  77.     FHTAddress    := @MyFHT;
  78.     FHTSize       := MaxFiles;
  79.  
  80.     Move(FHArray, MyFHT, 20);
  81.   end;
  82. end;
  83.  
  84. { Before resetting the FHT, close any files with handles > 20 }
  85.  
  86. procedure ResetFHT;
  87.  
  88. begin
  89.   with PSP^ do begin
  90.     FHTAddress := OldFHTAddress;
  91.     FHTSize    := OldFHTSize;
  92.  
  93.     Move(MyFHT, FHArray, 20);
  94.   end;
  95. end;
  96. -+----8<--------8<--------8<--------8<--------8<--------8<--------8<------
  97. By tweaking it a bit, you must be able to make it such that you can expand the
  98. FHT to the value set to the FILE= statement in CONFIG.SYS.
  99.  
  100. Grtz, l~) l~ l~)
  101.       l~\ l~ l~  ;-)
  102.  
  103. ---
  104.  * Origin: -=*#@ Programs Are Seen Clearly As Language @#*=- (RA 2:512/23)
  105.  
  106. @PATH: 512/23 0 1007 
  107.