 Read - Maple Help

FileTools[Binary]

 read binary data from a file Calling Sequence Read(file, type, num, opt1, opt2, ...) Parameters

 file - file descriptor or filename type - type of data to read num - number of elements to read byteorder = opt - (optional) byte order specification output = identical(list,Vector,Array) - (optional) output format Description

 • The Read(file, type, num) command reads num elements in type format from a file and returns them in the form of a list.
 • The following are valid values for type: integer, integer, integer, integer, float, float.  These types represent hardware data types. The integer[n] is an n byte integer, and float[n] is an n byte float.
 • The byteorder argument can have one of four values: big, little, network, and native.  This effects the order in which bytes are written for multi-byte data types.
 - big and little specify big endian and little endian respectively
 - network specifies network ordering (big endian)
 - native uses the native byte ordering
 If byteorder is not specified, it defaults to network.
 • The output argument lets you specify the return-value data structure used to store the binary data.  Using output=Array or output=Vector can be more efficient as these data structures will keep the data in the specified hardware format without requiring any conversion.  The default is output = list in order to be compatible with previous versions of Maple.
 • If file is the name of a file that has not been opened, Maple attempts to open the file before attempting to read the data.
 • An error is raised if file is not a valid descriptor or if it is the name of a file that does not exists. Examples

 > $\mathrm{num}≔1{256}^{3}+2{256}^{2}+3\cdot 256+4$
 ${\mathrm{num}}{≔}{1690960}$ (1)
 > $\mathrm{num2}≔4{256}^{3}+3{256}^{2}+2\cdot 256+1$
 ${\mathrm{num2}}{≔}{67305985}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{Write}\right]\left("testfile",\mathrm{integer}\left[4\right],\left[\mathrm{num}\right]\right)$
 ${4}$ (3)
 > $\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{Close}\right]\left("testfile"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{Read}\right]\left("testfile",\mathrm{integer}\left[4\right]\right)$
 $\left[{16909060}\right]$ (4)
 > $\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{Close}\right]\left("testfile"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{Read}\right]\left("testfile",\mathrm{integer}\left[4\right],'\mathrm{byteorder}'='\mathrm{little}'\right)$
 $\left[{67305985}\right]$ (5)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left("testfile"\right)$ Compatibility

 • The FileTools[Binary][Read] command was updated in Maple 2016.
 • The output parameter was updated in Maple 2016.