ReadFile - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


FileTools[Binary]

  

ReadFile

  

reads all binary data from a file

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

ReadFile(file, opts)

Parameters

file

-

file descriptor or filename

opts

-

(optional) one or more of the options described below

Options

ReadFile Options

• 

datatype=d

The type to assign to the data read, one of the following:

• 

integer[1], integer[2], integer[4], integer[8], float[4], float[8]. These types represent hardware data types. The integer[n] is an n byte integer, and float[n] is an n byte float.  If datatype is not specified, it defaults to integer[1].

• 

byteorder=b

Specify the byte order b in which bytes are read for multi-byte data types, where b is one of the names big, little, network, and native.

  

- big and little specify big endian and little endian, respectively

  

- network specifies the network ordering (big endian)

  

- native uses the native byte ordering

  

If byteorder is not specified, then it defaults to network.

• 

If file is the name of a file that has not previously been opened, ReadFile attempts to open the file before reading the data. In this case, ReadFile will also close the file after reading.

• 

An error is raised if file is not a valid descriptor or if it is the name of a file that does not exist.

Description

• 

The ReadFile(file) command reads all the data in datatype format from a file and returns it in the form of an Array.

• 

ReadFile will issue a warning message when the requested datatype is multi-byte and there is some extra data remaining at the end of the file.

Examples

> 

num≔1⁢2563+2⁢2562+3⋅256+4

num≔16909060

(1)
> 

num2≔4⁢2563+3⁢2562+2⋅256+1

num2≔67305985

(2)
> 

FileTools:-Binary:-WriteFile⁡testfile,integer4,num

4

(3)
> 

FileTools:-Binary:-ReadFile⁡testfile,datatype=integer4

16909060

(4)
> 

FileTools:-Binary:-ReadFile⁡testfile,datatype=integer4,byteorder=little

67305985

(5)
> 

FileTools:-Remove⁡testfile

Compatibility

• 

The FileTools[Binary][ReadFile] command was introduced in Maple 18.

• 

For more information on Maple 18 changes, see Updates in Maple 18.

See Also

file

FileTools[Binary]

FileTools[Binary][Read]

FileTools[Binary][WriteFile]

FileTools[Text][ReadFile]