Difference between revisions of "BINSEEK()"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
(Example)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to position the file pointer in binary file
 
Function to position the file pointer in binary file
 
  
 
==Syntax==
 
==Syntax==
BINSEEK([<expN1C>,<expN2>,<expN3>])
+
BINSEEK(<expN1C>,<expN2>,<expN3>)
 
+
  
 
==See Also==
 
==See Also==
 
[[BIN2I()]], [[BIN2L()]], [[BIN2W()]], [[BINCLOSE()]], [[BINCREATE()]], [[BINOPEN()]], [[BINREAD()]], [[BINWRITE()]], [[FSEEK()]], [[I2BIN()]], [[L2BIN()]]
 
[[BIN2I()]], [[BIN2L()]], [[BIN2W()]], [[BINCLOSE()]], [[BINCREATE()]], [[BINOPEN()]], [[BINREAD()]], [[BINWRITE()]], [[FSEEK()]], [[I2BIN()]], [[L2BIN()]]
 
  
 
==Description==
 
==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:
 
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:
  
 
+
{| class="wikitable" width="100%"
{| class="wikitable"
+
 
!Offset||Description
 
!Offset||Description
 
|-
 
|-
Line 25: Line 21:
 
|-
 
|-
 
|}
 
|}
 
  
 
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.
 
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==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
fd = binopen("file.obj")
+
fd = binopen("file.obj", 2)
 
count = binread(fd, 4)
 
count = binread(fd, 4)
 
count = bin2l(count)
 
count = bin2l(count)
Line 41: Line 35:
 
</code>
 
</code>
  
 
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Binary File Access]]
+
[[Category:Object Storage Functions]]
[[Category:Binary File Access Functions]]
+
[[Category:Lianja VFP Extensions]]
 +
[[Category:VFP Function Extensions]]

Latest revision as of 20:55, 28 February 2019

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", 2)
count = binread(fd, 4)
count = bin2l(count)
count = l2bin(count + 1)
binseek(fd, 512, 0)
binwrite(fd, count)
binclose(fd)