• Reference Guide


read_binary(f, type)
read_binary(bin, pos, typ)
The function reads a value encoded in the binary format from a file or from data of the Binary type.
In the first variant, The parameter f is a variable of the type File. The file must be open for reading.
The second variant takes data of the Binary type and a variable pos of the Int type that specifies a position within the binary data, from where should be the value read. On the return, the value of the pos variable is moved forward to point after the read data. Therefore, the pos variable is analogical to the file pointer.
The function reads a value of the type specified by the type parameter from the file, moves the file pointer, and returns the value read as its result. Hence, the parameter type determines both what to read and the type of the return value. This way, a value of any type previously written by the write_binary function can be read.
The formats stored for certain types are standardized. For these types, even data stored otherwise than with the write_binary function can be read. They are the following types:
Format Stored
Byte, Word, Dword, Qword, Int8, Int16, Int, Int64, Char
A binary format (1, 2, 4, or 8 bytes). The least significant byte stored first. A character is stored as 4-bytes of its Unicode value.
Eight bytes of the real number representation (ANSI/IEEE Standard 754-1985).
2 bytes (Word) specifying the string size; if the string size exceeds 65534 bytes, the 0xFFFF value is stored followed by 4 bytes of the size. The appropriate number of bytes follows.
An image stored in one of the supported standard bitmap formats.
The function read_binary(f, Bitmap) can be thus used to read standard image files.
Array of the types listed above
Appropriate number of elements according to the description above.
If an error occurs, an Error value is returned.

See Also