Syntax

Pref::postOutput(f)Pref::postOutput(NIL)Pref::postOutput()

Description

After the result x, say, of a MuPAD® command
is printed on the screen, f(x) is called and executed
before the next prompt for user input appears. This happens for any
output until the post-output is switched off via Pref::postOutput(NIL).

After the usual output of the result x of
a MuPAD command, the return value of f(x) is
printed on the screen with PRETTYPRINT = FALSE. However, f(x) does
not return any value to the MuPAD session. It cannot be accessed
via last.

Pref::postOutput() returns the current value
of the post-output function or NIL, respectively.

Pref::postOutput, possibly in conjunction
with Pref::postInput,
can be used to produce status information after each output. One may
think of timer informations, memory usage, result types etc.

Examples

Example 1

Here, Pref::postOutput is used to enumerate
the output line and display the type of the result. It uses the global
variable LineNumber which must be initialized before
any output is produced. The definition of the post-output operation
as well as the initialization of the global variable can be done in
the file "userinit.mu" which is read
automatically during start-up.

The following print command
returns the void object null() to the MuPAD session.
The output of null() is suppressed:

print("print returns the void object")

The following command is terminated by a semicolon to suppress
the output. Consequently, no post-output is created, either.

x := sin(2):

Post-output is switched off:

Pref::postOutput(NIL): delete LineNumber, x:

Example 2

For any command, the run time is to be computed and displayed.
The function declared in Pref::postInput sets
a global timer value TIME after each input. After
the output of the result, the function declared in Pref::postInput compares
the current time and the starting time TIME. The
current TEXTWIDTH is
used to prepend some suitable whitespace via stringlib::format to flush right the
timer information:

Example 3

The following post-output lists all identifiers with properties in the result of the last MuPAD command.
It extracts the indeterminates via indets and uses property::hasprop to query whether they
have properties: