read - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


read

the read statement and function

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

read filename

read(filename, options)

Parameters

filename

-

name or string

options

-

(optional) one or more optional arguments

Options

  

The following optional arguments are available.

• 

encoding = "utf-8"or "latin-1"

  

The default text encoding is "utf-8", which is compatible with ASCII (characters in the range 0-127) but not ISO/IEC 8859-1 ("high" or "extended" ASCII, characters in the range 128-255).  To read files including such characters, encoding="latin-1" can be used.

• 

propagateerrors = true or false 

  

If an error is raised while reading filename, propagateerrors determines if read propagates the error to the caller or captures it and handles it according to the inteface(errorbreak) setting.  The default is false.

Description

• 

The read statement is used to read Maple language files into Maple.

• 

If the filename ends with the characters ".m", the file is assumed to be in Maple internal format. The objects stored in the file are read into Maple and become available for use. This functionality is not intended for end users.

• 

If the file is in Maple language format, the statements in the file are read and executed as if they were being entered into Maple interactively, except that they are not echoed to the display unless interface(echo) is set to two or higher.

  

If an error occurs while evaluating the given file, the behavior of read is determined by the value of interface(errorbreak) and the propagateerrors option.

• 

If filename contains unusual characters (such as, "/" and "."), then the name must be enclosed in quotation marks. For more information on filenames, see file.

Examples

fileFileTools:-TemporaryFile,.mpl,directory=tempdir

file/tmp/mpldoc20/yYoYxV9R.mpl

(1)

FileTools:-Text:-WriteString(file,"hello := proc(who) cat(\"hi \",who); end;\n");

40

(2)

FileTools:-Text:-Closefile

readfile:

hellomom

hi mom

(3)

Compatibility

• 

The encoding option was introduced in Maple 2018.

• 

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

• 

The read command was updated in Maple 2025.

• 

The propagateerrors option was introduced in Maple 2025.

• 

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

See Also

convert

file

interface

name

save