Functions > Reading and Writing Files > Binary Data Files
Binary Data Files
There are two functions that are used to read from or write to a binary file:
READBIN("file", "type", [[endian], [cols], [skip], [maxrows]])—Returns an array containing the binary data in file.
WRITEBIN("file", "type", endian, M)—Writes an array of scalars to the binary data file named file.
file is a string containing the filename or the full pathname and filename.
type is a string that specifies the data format used in the file. READBIN supports the following data types:
byte - 8-bit unsigned integer.
double - 64-bit floating point number.
float - 32-bit floating point number.
int16 - signed 16-bit integer.
int32 - signed 32-bit integer.
uint16 - unsigned 16-bit integer.
uint32 - unsigned 32-bit integer.
endian (optional for READBIN) indicates whether the data in the file is big-endian (high byte first) or little-endian (low byte first). Big-endian is represented by a 1, while little-endian is represented by a 0. If no value is specified, endian is assumed to be 0.
If you are not sure whether your data is written in big-endian (the Macintosh standard) or little-endian (the IBM-PC standard) format, please consult the system documentation for your data source before relying upon the accuracy of any result from READBIN or WRITEBIN.
cols (optional) is the positive integer number of columns per row in the input file. Default is 1.
skip (optional) is the nonnegative integer number of bytes at the beginning of the file to ignore before reading in data. Default is 0.
maxrows (optional) is the nonnegative integer maximum number of rows of data to be read from the data file. Default is 0 (no limit).
M is an array.
Was this helpful?