home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / textfile.swg / 0001_FASTIO.PAS.pas next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  1.1 KB  |  47 lines

  1.  GB>Could you Write a MCSEL ;-) wich gives us some hints For making Text i/o
  2.  GB>_much_ faster ? I read that about the SetTextBuf although I never tried
  3.  GB>it. What are other examples? Some little example-sources ?
  4.  
  5. Type BBTYP   = ^BIGBUF;
  6.      BIGBUF  = Array[0..32767] of Char;
  7.  
  8. Var BUFFin   : BBTYP;        { general-use large Text I/O buffer }
  9. Var BUFFOUT  : BBTYP;
  10.     F        : Text;
  11.     S        : String;
  12.  
  13. Procedure BBOPEN (Var F : Text; FN : String; OMODE : Char;
  14.                   Var BP : BBTYP);
  15. Var S : String;
  16. begin
  17. {$I-}
  18.   Assign (F,FN); New (BP); SetTextBuf (F,BP^);
  19.   Case UpCase(OMODE) of
  20.     'R' : begin
  21.             Reset (F); S := 'Input'
  22.           end;
  23.     'W' : begin
  24.             ReWrite (F); S := 'Output'
  25.           end;
  26.     'A' : begin
  27.             Append (F); S := 'Extend'
  28.           end
  29.     else
  30.   end;
  31. {$I+}
  32.   if Ioresult <> 0 then
  33.     begin
  34.       Dispose (BP); FATAL ('Cannot open '+FN+' For '+S+' - Terminating')
  35.     end
  36. end;  { BBOPEN }
  37.  
  38. to use:
  39.  
  40.   BBOPEN (F,'myFile.txt',r,BUFFin);
  41.   While not Eof (F) do
  42.     begin
  43.       readln (F,S);
  44.       etc.
  45.     end;
  46.   Close (F); Dispose (BUFFin)
  47.