SetTextBuf
Jump to navigation
Jump to search
Assigns an I/O buffer to a text file.
- Declaration
procedure SetTextBuf(var F: Text; var Buf [ ; Size: Word ] );
- Target
- Windows, Real, Proctected
- Remarks
- SetTextBuf should never be applied to an open file, although it can be called immediately after Reset, Rewrite, and Append.
- If you call SetTextBuf on an open file once I/O operations have taken place, loss of data can result because of the change of buffer.
- Pascal does not ensure that the buffer exists for the entire duration of I/O operations on the file. A common error is to install a local variable as a buffer, then use the file outside the procedure that declared the buffer.
Sample Code
{Settxtbf.PAS} {Sample code for the SetTextBuf procedure.} { For Windows: } { uses WinCrt; } var F: Text; Ch: Char; Buf: array[1..4095] of Char; { 4K buffer } begin { Get file to read from command line } Assign(F, ParamStr(1)); { Bigger buffer for faster reads } SetTextBuf(F, Buf); Reset(F); { Dump text file onto screen } while not Eof(f) do begin Read(F, Ch); Write(Ch); end; end.