Difference between revisions of "BINREAD()"

From Lianjapedia
Jump to: navigation, search
 
(Example)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to read a character string from a binary file
 
Function to read a character string from a binary file
 
  
 
==Syntax==
 
==Syntax==
BINREAD([<expN1>,<expN2>])
+
BINREAD(<expN1>,<expN2>)
 
+
  
 
==See Also==
 
==See Also==
 
[[BIN2I()]], [[BIN2L()]], [[BIN2W()]], [[BINCLOSE()]], [[BINCREATE()]], [[BINOPEN()]], [[BINSEEK()]], [[BINWRITE()]], [[FREAD()]], [[FREADSTR()]], [[I2BIN()]], [[L2BIN()]]
 
[[BIN2I()]], [[BIN2L()]], [[BIN2W()]], [[BINCLOSE()]], [[BINCREATE()]], [[BINOPEN()]], [[BINSEEK()]], [[BINWRITE()]], [[FREAD()]], [[FREADSTR()]], [[I2BIN()]], [[L2BIN()]]
 
  
 
==Description==
 
==Description==
 
The BINREAD() reads a character string from a binary file that was 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> value represents the number of bytes to read.  The BINREAD() function reads the specified number of bytes from the file starting at the current position of BINSEEK().  BINREAD() returns the character string in the specified length of <expN2> if successful, or a string of length zero if unsuccessful.  The binary conversion functions may be used in conjunction with the binary file functions.
 
The BINREAD() reads a character string from a binary file that was 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> value represents the number of bytes to read.  The BINREAD() function reads the specified number of bytes from the file starting at the current position of BINSEEK().  BINREAD() returns the character string in the specified length of <expN2> if successful, or a string of length zero if unsuccessful.  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 26: Line 22:
 
</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 12:21, 26 February 2019

Purpose

Function to read a character string from a binary file

Syntax

BINREAD(<expN1>,<expN2>)

See Also

BIN2I(), BIN2L(), BIN2W(), BINCLOSE(), BINCREATE(), BINOPEN(), BINSEEK(), BINWRITE(), FREAD(), FREADSTR(), I2BIN(), L2BIN()

Description

The BINREAD() reads a character string from a binary file that was 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> value represents the number of bytes to read. The BINREAD() function reads the specified number of bytes from the file starting at the current position of BINSEEK(). BINREAD() returns the character string in the specified length of <expN2> if successful, or a string of length zero if unsuccessful. 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)