Function to position the file pointer in binary file
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:
|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.
fd = binopen("file.obj", 2) count = binread(fd, 4) count = bin2l(count) count = l2bin(count + 1) binseek(fd, 512, 0) binwrite(fd, count) binclose(fd)