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

Online Help

All Products    Maple    MapleSim


StringTools

  

FormatMessage

  

format a message string using %-interpolation

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

FormatMessage( msgString, msgArg1, msgArg2, ... )

Parameters

msgString

-

string

msgArg1, msgArg2, ...

-

arguments to substitute into msgString

Description

• 

The FormatMessage function accepts the same formatting arguments as an invocation of the error command or a call to the WARNING function.

  

Unlike raising an exception or displaying a warning, a call to FormatMessage returns a string containing the message. That string will contain the same text as an error or warning, but with no "Error," or "Warning," prefix.

• 

For details on the construction of FormatMessage %n parameter forms (also supported by error and WARNING), refer to Error and Warning Message Formatting.

• 

This function is part of the StringTools package, and so it can be used in the form FormatMessage(..) only after executing the command with(StringTools). However, it can always be accessed through the long form of the command by using the form StringTools:-FormatMessage(..).

  

Note: The %n input of FormatMessage should be used for showing a message to a human, not for formatting Maple objects for parsing by Maple or other programs. For more sophisticated formatting capabilities, see sprintf.

Examples

withStringTools:

FormatMessagefoo

foo

(1)

FormatMessagefoo,bar,2,3

foo, bar, 2, 3

(2)

FormatMessagefoo %1,bar,2,3

foo bar

(3)

FormatMessagefoo %2,bar,2,3

foo 2

(4)

FormatMessagefoo %3,bar,2,3

foo 3

(5)

FormatMessagefoo %4,bar,2,3

foo %4

(6)

FormatMessagefoo %0,bar,2,3

foo bar, 2, 3

(7)

FormatMessagefoo %-2,bar,2,3

foo 2nd

(8)

FormatMessagefoo %-3,bar,2,3

foo 3rd

(9)

FormatMessageThere %{1|are|is|are} %{1|no|one|many} thing%{1|s||s}.,0

There are no things.

(10)

FormatMessageThere %{1|are|is|are} %{1|no|one|many} thing%{1|s||s}.,1

There is one thing.

(11)

FormatMessageThere %{1|are|is|are} %{1|no|one|many} thing%{1|s||s}.,5

There are many things.

(12)

FormatMessagefoo %-1,N,2,3

foo N-th

(13)

fopen2

Error, invalid input: fopen expects its 1st argument, file, to be of type {string, symbol}, but received 2

lastexception

0,invalid input: %1 expects its %-2 argument, %3, to be of type %4, but received %5,fopen,1,file,string,symbol,2

(14)

FormatMessagelastexception2..1

invalid input: fopen expects its 1st argument, file, to be of type {string, symbol}, but received 2

(15)

Compatibility

• 

The StringTools[FormatMessage] command was updated in Maple 15.

See Also

error

fopen

lastexception

sprintf

string

StringTools

WARNING