Previous Page Next Page Contents

Pref::postOutput -- actions after any output

Introduction

Pref::postOutput controls user defined actions directly after any output.

Call(s)

Pref::postOutput( <func>)

Parameters

func - function to be executed after output, or NIL

Returns

the last defined function

Related Functions

Pref::postInput, Pref::promptString

Details

Example 1

>>

Example 2

Pref::postOutput will be used to numerate the output lines and show the type of the result. The global variable NumberOfLine must be initialized with 0. This all can be done in the file ``userinit.mu''.

>> NumberOfLine:= 0:
   Pref::postOutput(proc()
                    begin
                      NumberOfLine:= NumberOfLine + 1;
                      stringlib::format(NumberOfLine, TEXTWIDTH, Right)."\n".
                      stringlib::format("Type: ".expr2text(map([args()], domtype)),
                                        TEXTWIDTH, Right)
                    end_proc):

Example 3

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.

Example 4

Show all identifiers of the result, that have properties assumed by the user.

The first assignment to ID selects all identifiers of the output, that have properties. The second assignment to ID collects the properties of all identifiers.

>> Pref::postOutput(proc()
                      local ID;
                    begin
                      if args(0) > 0 then
                        ID := select(indets(args()), property::hasprop);
                      else
                        ID := {};
                      end_if;
                      if nops(ID) > 0 then
                        stringlib::format("Props: ".expr2text(op(ID)),
                                          TEXTWIDTH, Right)
                      else
                        null()
                      end_if
                    end_proc):
   assume(a>0): a
                                     a
                                                             Props: a

The output depends on the value of the variable TEXTWIDTH.

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000