DADiSP Worksheet Functions > Function Categories > File Manipulation > FSEEK

 

FSEEK

Purpose:

Moves the file pointer to the location indicated by the specified origin and modified by the specified offset.

Syntax:

FSEEK("filename", offset, mode)

"filename"

-

A string. The name of the file to move the seek location.

offset

-

An integer. Position to seek in bytes relative to the mode.

mode

-

An integer. The position from which the offset is calculated:

0:

Seek relative to the beginning of the file.

1:

Seek relative to the current file position.

2:

Seek relative to the end of the file. 

Returns:

A 1 if the pointer move is successful; otherwise it returns nothing.

Example:

If the file myheader.hdr contains the following:

 

DATASET Pressure
SERIES PTop, PBottom

 

then the commands:

 

fopen("myheader.hdr", "r+")
fseek("myheader.hdr", 18, 0)
fgets("myheader.hdr")

 

displays the string SERIES PTop, PBottom on the status line.

 

fseek(filename, 0, 2)

 

moves the pointer to the end of the file.

Remarks:

File must be opened with FOPEN before using FSEEK. FSEEK changes the read/write position of the file specified by filename.

 

FTELL can be used to determine the byte position of the file pointer.

See Also:

FCLOSE

FOPEN

FREADB

FTELL