FileSeek

 

The 'FileSeek' function sets the new pointer in the specified file.

 

void FileSeek(DWORD handle, DWORD offset, WORD direction);

 

Remarks : Usually, if a file is opened, the pointer is located at start-point of the file. If you execute file-read or file-write, the pointer is backward moved by the length of input data.

 

Parameters

DWORD handle : 'Return Value' of the 'FileOpen' function

DWORD offset : size of movement ( + [plus] : forward,  - [minus] : backward )

WORD orgin : base point (0 = current-point of the file, 1 = start-point of the file , 2 = end-point of the file)

 

Return Value

none

 

Example 1

handle = @FileOpen("C:\\EX.TXT", "r");

if(handle != 0)

@FileRead(handle, buf, 3);

@FileClose(handle);

}

Description : Assume that data of 'EX.TXT' file are 'ABCDEFGHIJ'. If you excute the above statement, 'ABC' is stored in string-variable named 'buf'.

 

Example 2

handle = @FileOpen("C:\\EX.TXT", "r");

if(handle != 0)

{

@FileSeek(handle, 5, 1);

@FileRead(handle, buf, 3);

@FileClose(handle);

}

Description : Assume that data of 'EX.TXT' file are 'ABCDEFGHIJ'. If you excute the above statement, 'FGH' is stored in string-variable named 'buf'.

 

Example 3

handle = @FileOpen("C:\\EX.TXT", "r");

if(handle != 0)

{

@FileSeek(handle, -7, 2);

@FileRead(handle, buf, 3);

@FileClose(handle);

}

Description : Assume that data of 'EX.TXT' file are 'ABCDEFGHIJ'. If you excute the above statement, 'DEF' is stored in string-variable named 'buf'.

 

Example 4

handle = @FileOpen("C:\\EX.TXT", "r");

if(handle != 0)

{

@FileSeek(handle, 5, 1);

@FileSeek(handle, -3, 0);

@FileRead(handle, buf, 3);

@FileClose(handle);

}

Description : Assume that data of 'EX.TXT' file are 'ABCDEFGHIJ'. If you excute the above statement, 'CDE' is stored in string-variable named 'buf'.

 

Example 5

handle = @FileOpen("C:\\EX.TXT", "r");

if(handle != 0)

{

@FileSeek(handle, -7, 2);

@FileSeek(handle, 4, 0);

@FileRead(handle, buf, 3);

@FileClose(handle);

}

Description : Assume that data of 'EX.TXT' file are 'ABCDEFGHIJ'. If you excute the above statement, 'HIJ' is stored in string-variable named 'buf'.