BINREAD()

From Recital Documentation Wiki
Jump to: navigation, search

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


Products

Recital Server, Recital