Read - 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]

  

Read

  

read binary data from a file

 

Calling Sequence

Parameters

Description

Examples

Compatibility

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[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.

• 

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

num12563+22562+3256+4

num16909060

(1)

num242563+32562+2256+1

num267305985

(2)

FileToolsBinaryWritetestfile,integer4,num

4

(3)

FileToolsBinaryClosetestfile:

FileToolsBinaryReadtestfile,integer4

16909060

(4)

FileToolsBinaryClosetestfile:

FileToolsBinaryReadtestfile,integer4,byteorder=little

67305985

(5)

FileToolsRemovetestfile

Compatibility

• 

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

• 

The output parameter was updated in Maple 2016.

See Also

file

FileTools[AtEndOfFile]

FileTools[Binary]

FileTools[Binary][Close]

FileTools[Binary][ReadFile]

FileTools[Binary][Write]

FileTools[Remove]

IO_errors