FPOS macro

Sets the position of a file. The position of a file is where a character is read from or written to by an FREAD, FREADLN, FWRITE, or FWRITELN function. Use FPOS when you want to write characters to or read characters from specific locations. For example, to append text to the end of a file, you must set the position to the end of the file; otherwise, you might accidentally overwrite existing characters in the file.

Syntax

FPOS(file_num, position_num)

File_num    is the unique ID number of the file for which you want to set the position. File_num is returned by a previously executed FOPEN function. If file_num is not valid, FPOS returns the #VALUE! error value.

Position_num    is the location in the file that a character will be read from or written to.

 

Whenever you read a character from or write a character to a file, the file's position is automatically incremented.

Examples

The following statement starts a loop that executes until the position in the open file identified as FileNumber reaches the end of the file:

=WHILE(FPOS(FileNumber)<=FSIZE(FileNumber))

Related Functions

FCLOSE   Closes a text file

FOPEN   Opens a file with the type of permission specified

FREAD   Reads characters from a text file

FREADLN   Reads a line from a text file

FWRITE   Writes characters to a text file

FWRITELN   Writes a line to a text file

Return to index