Siebel eScript Language Reference > Siebel eScript Commands > File I/O Methods in eScript >

Clib.fgetpos() Method


This method stores the current position of the pointer in a file.

Syntax

Clib.fgetpos(filePointer, position)

Parameter
Description

filePointer

A file pointer as returned by Clib.fopen()

position

The current position of filePointer

Returns

0 if successful; otherwise, nonzero, in which case an error value is stored in the errno property.

Usage

This method stores the current position of the file cursor in the file indicated by filePointer for future restoration using fsetpos(). The file position is stored in the variable position; use it with fsetpos() to restore the cursor to its position.

Example

This example writes two strings to a temporary text file, using Clib.fgetpos() to save the position where the second string begins. The program then uses Clib.fsetpos() to set the file cursor to the saved position so as to display the second string.

function Test_Click ()
{
   var position;
   var fp = Clib.tmpfile();
   Clib.fputs("Melody\n", fp);
   Clib.fgetpos(fp, position)
   Clib.fputs("Lingers\n", fp);
   Clib.fsetpos(fp, position);
   var msg = Clib.fgets(fp));
   Clib.fclose(fp);
   TheApplication().RaiseErrorText(msg);
}

See Also

Clib.feof() Method
Clib.fsetpos() Method
Clib.ftell() Method

Siebel eScript Language Reference