ReadFile - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

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

num12563+22562+3256+4

num16909060

(1)

num242563+32562+2256+1

num267305985

(2)

FileTools:-Binary:-WriteFiletestfile,integer4,num

4

(3)

FileTools:-Binary:-ReadFiletestfile,datatype=integer4

16909060

(4)

FileTools:-Binary:-ReadFiletestfile,datatype=integer4,byteorder=little

67305985

(5)

FileTools:-Removetestfile

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]

 


Download Help Document