## `Pref::postInput` -- actions after input

#### Introduction

With `Pref::postInput`, actions directly after the data input can be initiated.

#### Call(s)

`Pref::postInput(value)`

#### Parameters

`value` | - | function to be executed after data input

#### Returns

the previously defined function

#### Related Functions

`Pref::postOutput`, `Pref::promptString`

#### Details

- With `Pref::postInput` a function can be defined to initiate actions after ending every complete input line with `<RETURN>`.
- The function will be called with the complete input line as argument.
- After the execution of the defined function the normally execution will be continued.
- `Pref::postInput` in joint with `Pref::promptString` und `Pref::postOutput` can be used to create status informations about evaluation. Possibilities are informations to time, memory usage, types of results etc. (see `Pref::postOutput`)
- A call of `Pref::postInput` without arguments will return the current value. The argument `NIL` will reset the default value, which is `NIL`.

#### Example 1

`Pref::postInput` will be used to numerate the input lines in joint with `Pref::promptString`. The global variable `NumberOfLine` must be initialized with `0`. This all can be done in the file ```userinit.mu`''.

    >> NumberOfLine:= 0:
       Prompt:= Pref::promptString():
       Pref::postInput(proc()
                       begin
                         NumberOfLine:= NumberOfLine + 1;
                         Pref::promptString(expr2text(NumberOfLine) . Prompt)
                       end_proc):

#### Example 2

Time mesure in seconds.

    >> Pref::postInput(() -> (TIME:= time())):
       Pref::postOutput(proc()
                          local Time;
                        begin
                          Time:= trunc((time() - TIME)/1000);
                          stringlib::format("Time: ".expr2text(Time)." s",
                                            TEXTWIDTH, Right)
                        end_proc):
       T:= time(): while time() - T < 1000 do null() end_while

                                                                Time: 2 s

The output depends on the value of the variable `TEXTWIDTH`.

#### Changes

- no changes

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