Controls the amount of printed output from Darwin. Normally, the result of every statement executed at the top level is printed. This printing is controlled by a global variable named printlevel. By default this variable is assigned 1. At this level, expressions or assignments at the top level and nested one level will be printed.
This is an assignment at the top level, it is printed.
> a := 1;
a := 1
This is an expression nested one level, it is printed.
> if a=1 then 7 fi;
7
This is an assignment nested two levels deep, nothing is printed.
> for i to 2 do if a=1 then c := 1 fi od;
By increasing printlevel by 1, the printing will happen one level deeper.
> printlevel := 2;
printlevel := 2
> for i to 2 do if a=1 then c := 1 fi od;
c := 1 c := 1
By increasing printlevel to 5, the execution of any function called at the top level will be printed. This becomes a very valuable tool for debugging and inspecting Darwin functions.
> f := x -> x+1;
f := x -> x+1
> printlevel := 5;
printlevel := 5
> f(1);
{--> enter f, args = 1
2
<-- exit f = 2}
2
By increasing printlevel to 10 the statements in a nested function call will be displayed.
> g := x->f(x);
> printlevel := 10;
> g(1);
{--> enter g, args = 1
{--> enter f, args = 1
2
<-- exit f = 2}
2
<-- exit g = 2}
2
Some additional printing is also controlled by printlevel. If printlevel is higher than 2, then in case of an error, a complete traceback is printed with all the local variables, parameters and their values. Many functions use printlevel to print additional information about the problem they are solving. Users are encouraged to use printlevel for this purpose. In this case, a value of 1 should not print anything, and values greater than 4 are not recommended, since the user will be forced to see the trace of top level functionc calls.
> my_function := proc( x )
. . . .
if printlevel > 2 then printf( 'hyperbolic cut method used
' ) fi;
. . . .
end;
Notice that if you want to modify printlevel inside a function, you should declare it in the global list, else by default it becomes a local variable.