!Trace file decoder.  This is the original (non-JHB) version

%include "SYSTEM:CONFIG.INC"
%include "Inc:UTIL.IMP"

%constinteger trace in length = 23

%recordformat trace fm(%integer context, inout, %string(55) text)
%recordformat tbuff fm(%integer q,
                       %record(trace fm)%array t(0 : tbuffs),
                       %integer p)
%constinteger trace in  = 0
%constinteger trace out = 1

%begin
   %record(tbuff fm)%name tbuff
   %record(trace fm)%name t
   %integer s, l, i, context
   %string(127) command = ""
      %on 9 %start;  %stop;  %finish
      connect file("$:TRACE", 0, s, l)
      tbuff == record(s)
      ! printstring("Pointer p at ");  write(tbuff_p, 0);  newline
      ! printstring("Pointer q at ");  write(tbuff_q, 0);  newline
!      prompt("Context: ");  read(context)
      context = stoi(cliparam)
      %for i = tbuff_p, 1, tbuffs + tbuff_q %cycle
         t == tbuff_t(i & tbuffs)
         ! printstring("Slot ");  write(i & tbuffs, 0)
         ! printstring(": context ");  write(t_context, 0)
         ! newline
         %if t_context = context %start
            %if t_inout = trace in %start
               %if command # "" %start
                  spaces(trace in length - length(command))
                  printstring(command)
                  printstring(" / *** No reply ***")
                  newline
               %finish
               command = t_text
            %else
               command = "..." %if command = ""
               spaces(trace in length - length(command))
               printstring(command)
               printstring(" / ")
               printstring(t_text)
               newline
               command = ""
            %finish
         %finish
      %repeat
      %if command # "" %start
         spaces(trace in length - length(command))
         printstring(command)
         printstring(" / *** No reply ***")
         newline
      %finish
%end %of %program
