File.Seek

Top  Previous  Next

 

Syntax

function File.Seek(F: pointer; NewPos: large-integer; SeekOrigin: integer): integer

 

Alternative Names

ibec_fs_SetSize

 

Description

Modifies the current position of the given file-stream.

 

The new position is based on the value for NewPos in combination with the SeekOrigin, which is one of the following constants:

__soFromBeginning

NewPos is the absolute position, starting from position 0.

__soFromCurrent

The value for NewPos is added to the current position.

__soFromEnd

NewPos is subtracted from the size, if NewPos is a larger number than the file size, the new position is set to 0.

 

The Return value is the actual new position of the file-stream.

 

See also

File.GetPosition
File.SetPosition

 

Example

execute udsblock returns (valueout varchar(1024))

as

begin

  /* open text file with UTF8 encoding preamble */ 

  fs = File.Open('c:\data\utf8text.txt', __fmOpenReadWrite + __fmShareDenyWrite);

  try

    /* read all available lines */

    while not File.EOF(fs)

    do begin

     /* get position before reading a line */

     p = File.GetPosition(fs);

         valueout = File.ReadLn(fs);

     suspend;

       end

 

    /* go back to the beginning */

    File.Seek(fs, 0, __soFromBeginning);

 

    /* read all available lines again */

    while not File.EOF(fs)

    do begin

     /* get position before reading a line */

     p = File.GetPosition(fs);

         valueout = File.ReadLn(fs);

     suspend;

       end

  finally

    File.Close(fs);

  end

end