## `Pref::output` -- influence output of objects

#### Introduction

With `Pref::output` the output of objects can be influenced.

#### Call(s)

`Pref::output(function)`

#### Parameters

`function` | - | function, that influence the output

#### Returns

the previously defined value

#### Related Functions

`Pref::postOutput`, `Pref::postInput`, `Pref::keepOrder`

#### Details

- With `Pref::output` a function can be defined that manipulates the output of objects.
- The given function will be called before any object will be outputted. The argument is the object, that will be outputted. The result of the function will be outputted instead of the given object.
- A call of `Pref::output` without arguments will return the current value. The argument `NIL` will reset the default value, which is `NIL`.

#### Example 1

All numbers shall be displayed as floating point numbers, but the input and calculations should not be influenced. Therefor a function, that applies `float` to all numeric objects, will be mapped to all objects of the result.

    >> Pref::output(
         proc()
         begin
           map(args(), proc(num)
                       begin
                         if testtype(num, Type::Numeric) then
                           float(num)
                         else
                           num
                         end_if
                       end_proc)
         end_proc):
       1, 528/44, 194/8, 2 + 4/5*I

                           1.0, 12.0, 24.25, 2.0 + 0.8 I

In the next example the procedure `generate::TeX` will be applied to every output, before any object will be displayed.

    >> Pref::output(generate::TeX):
       sqrt(x^2 - 1/x)

                           "\\sqrt{x^2 - \\frac{1}{x}}"

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000