TDosStream.Seek procedure
Set file position.
Declaration
procedure Seek(Pos: LongInt); virtualDescription
If the stream's status is
stOK, then
Seek sets the
file position to
Pos.
Pos is a zero-based offset, counted from
the beginning of the file.
Errors
In case an error occurs, the stream's status is set to
stSeekError,
and the OS error code is stored in
ErrorInfo.
See also
Example: ex17
Program ex17;
{ Program to demonstrate the TStream.Seek method }
Uses Objects;
Var L : String;
Marker : Word;
P : PString;
S : PDosStream;
begin
L:='Some constant string';
{ Buffer size of 100 }
S:=New(PDosStream,Init('test.dat',stcreate));
Writeln ('Writing "',L,'" to stream.');
S^.WriteStr(@L);
Marker:=S^.GetPos;
Writeln ('Set marker at ',Marker);
L:='Some other constant String';
Writeln ('Writing "',L,'" to stream.');
S^.WriteStr(@L);
S^.Close;
S^.Open (stOpenRead);
Writeln ('Size of stream is : ',S^.GetSize);
Writeln ('Seeking to marker');
S^.Seek(Marker);
P:=S^.ReadStr;
L:=P^;
DisposeStr(P);
Writeln ('Read "',L,'" from stream.');
S^.Close;
Dispose (S,Done);
end.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
