BINSEEK()

From Recital Documentation Wiki
Jump to: navigation, search

Purpose

Function to position the file pointer in binary file


Syntax

BINSEEK([<expN1C>,<expN2>,<expN3>])


See Also

BIN2I(), BIN2L(), BIN2W(), BINCLOSE(), BINCREATE(), BINOPEN(), BINREAD(), BINWRITE(), FSEEK(), I2BIN(), L2BIN()


Description

The BINSEEK() function is used to position to a byte offset within a binary file opened with the BINCREATE() or BINOPEN() functions. The <expN1> is the file descriptor which was returned when the file was opened with either the BINCREATE() or BINOPEN() functions. The <expN2> is the byte offset to move the file pointer based on the value defined by <expN3>. The value of <expN3> represents a positioning mode that defines the position from which to start the byte offset. The positioning mode options are:


Offset Description
0 Start from the beginning of file
1 Start from the current position
2 Start from the end of file


The BINSEEK() function returns the new file position relative to the beginning of the file. The binary conversion functions may be used in conjunction with the binary file functions.


Example

fd = binopen("file.obj")
count = binread(fd, 4)
count = bin2l(count)
count = l2bin(count + 1)
binseek(fd, 512, 0)
binwrite(fd, count)
binclose(fd)


Products

Recital Server, Recital