Sfairadora

  • Reference Guide

write_binary

f <- write_binary(type, value)
bin <- write_binary(pos, type, value)
The function writes data in the binary format to a file or to a variable of the Binary type.
In the first variant, the parameter f is a variable of the type File. The file must be open for writing.
The second variant takes a variable bin 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 written. The function stores the value to the specified position. On the return, the value of the pos variable is moved forward to point after the written data. Therefore, the pos variable is analogical to the file pointer.
The function stores a value of the type determined by the type parameter. If the parameter value is not of the specified type, it is converted. Before the function returns, the file pointer is moved to the end of the written data. The stored data can be read by the read_binary function.
The formats stored for certain types are standardized. For these types, the data stored with the write_binary function can be used even otherwise than just reading by the read_binary function. For details, see the read_binary function.

Return Value

An l-value referring to the variable f is returned. If an error occurs, an Error value is returned.

See Also