Name
Seek Procedure
Syntax
procedure Seek(var F: File; RecordNumber: LongInt);
Description
The Seek
procedure moves the file position to
RecordNumber
. Seek
is
not a real
function.
Tips and Tricks
You cannot call
Seek
for aTextFile
. If you must seek to a specific position, use the Windows API:
// Seek to a byte position in a text file. See SetInOutRes for the // same procedure with error-handling. Assume the buffer is empty. procedure TextSeek(var F: TextFile; Pos: LongInt); begin SetFilePointer(TTextRec(F).Handle, Pos, nil, File_Begin); end;
The start of the file is record number 0.
If
F
is an untypedFile
, the record size is set when you open the file withReset
orRewrite
.
Example
// Rewind a file to the beginning. Seek(F, 0); // Jump to the end of a file. Seek(F, FileSize(F));
See Also
File Keyword, FilePos Function, IOResult Function |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.