This is for mere debugging purposes: Do some printout so that one can see what the program is doing.
There are several levels of logging: Everything with a less or lower lev- parameter than the global 'level'-variable will be printed. Use 'Log.level:= 0' to switch off logging
MODULE; IMPORT Wr, Fmt, Thread, Process; FROM Stdio IMPORT stdout; <*FATAL Wr.Failure, Thread.Alerted*> CONST indent = " "; (* Text used for each level of indentation *) VAR proccount: CARDINAL:= 0; (* indendation-level (set by 'In/ExitProc') *) first:= TRUE; (* first to write into a new line *) PROCEDURE Log InProc (name: TEXT; lev:= 1) = BEGIN IF lev <= level THEN PutText("------- "&name&"-----------"); INC(proccount); Nl(lev:=lev); END (*IF*) END InProc; PROCEDUREExitProc (comment: TEXT:= ""; lev:= 1) = BEGIN IF lev <= level THEN DEC(proccount); PutText("------- "&comment); Nl(lev:= lev); END (*IF*) END ExitProc; PROCEDUREPutText (t: TEXT; lev:= 1) = BEGIN IF lev <= level THEN IF first THEN first:= FALSE; Wr.PutText(stdout, linestart); FOR i:= 1 TO proccount DO Wr.PutText(stdout, indent) END; END; (*IF*) Wr.PutText(stdout, t); Wr.Flush(stdout); END (*IF*) END PutText; PROCEDUREPutInt (i: INTEGER; lev:= 1) = BEGIN IF lev <= level THEN PutText(Fmt.Int(i)); END (*IF*) END PutInt; PROCEDURENl (lev:= 1) = BEGIN IF lev <= level THEN Wr.PutText(stdout, "\n"); Wr.Flush(stdout); first:= TRUE; END (*IF*) END Nl; PROCEDURESeparate (lev:= 1) = BEGIN IF lev <= level THEN Nl(lev:= lev); Wr.PutText(stdout, "------------------"); Nl(lev:= lev); END (*IF*) END Separate; PROCEDURECrashPoint (nr: INTEGER) = BEGIN IF crash = nr THEN PutText("crash-point "); PutInt(nr); PutText(" reached"); Nl(); Process.Exit(nr); END; END CrashPoint; BEGIN level := 0; END Log.