Pref::postInput -- actions
after input
IntroductionWith Pref::postInput, actions directly after the data
input can be initiated.
Call(s)Pref::postInput(value)
Parametersvalue |
- | function to be executed after data input |
Returnsthe previously defined function
Related
FunctionsPref::postOutput,
Pref::promptString
DetailsPref::postInput a function can be defined to
initiate actions after ending every complete input line with
<RETURN>.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)Pref::postInput without arguments will
return the current value. The argument NIL will reset the
default value, which is NIL.
Example
1Pref::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
2Time 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.