%begin
%include "inc:util.imp"

%recordformat pcbf(%integer uno, stn, %string (255) user, dir)
%record (pcbf) temp
%record (pcbf) %array pcb(0:63)
%string (255) %array new, trace(0:63)

%routine wait(%integer msec)
   msec = cputime + msec
   %cycle; %repeatuntil cputime>=msec
%end

%integerfn hex2(%string (255) s, %integer i)
   %integer a,b
   a=charno(s,i); a=a-7 %if a>'9'; %if a=' ' %then a=0 %else a=a-'0'
   b=charno(s,i+1); b=b-7 %if b>'9';%if b=' ' %then b=0 %else b=b-'0'
   %result = a<<4+b
%end

%routine unpack(%string (255) s, %record (pcbf) %name pcb)

  %string(255) %fn str7(%integer i)
     %string (255) t
     %integer j,k
     j=0
     %for k=0, 1, 7 %cycle
        j=j+1 %and charno(t, j) = charno(s, k+i) {%if charno(s, k+i) # ' '}
     %repeat
     length(t) = j
     %result=t
  %end

  pcb_uno=hex2(s, 6)
  pcb_stn=hex2(s, 10)
  pcb_user=str7(16)
  pcb_dir=str7(24)
%end

%predicate interested in(%integer stn)
   !Not 52
   %constintegerarray stns(0:23)= %c
   16_22,16_4D,16_20,16_13,16_38,16_19,16_1E,16_32,
   16_27,16_3A,16_36,16_17,16_1D,16_53,16_23,16_18,
   16_33,16_21,16_55,16_FF,16_24,16_45,16_41,16_4F
   %integer i
   %for i=0,1,23 %cycle; %true %if stns(i)=stn; %repeat
   %false
%end

%routine read uno file
   %string (255) s
   %integer i
   %on 3,9 %start; ->eof; %finish
   openinput(1, "$:unos")
   %for i=0,1,63 %cycle; pcb(i)_user="-       "; %repeat
   %cycle
      readline(s)
      unpack(s, temp)
      pcb(temp_uno) = temp %if interested in(temp_stn)
   %repeat
eof:
   close input
%end

%predicate find(%string (255) text, %string(255) %arrayname list(0:*))
   %integer i
   i=0
   %cycle
      %false %if list(i)=""
      %true %if list(i)=text
      i=i+1
   %repeat
%end

%routine dump xno file
   %string (255) s, text
   %string (255) %array new(0:63)
   %integer uno, l, i
   %on 3,9 %start; ->eof; %finish
   openinput(1, "$:xnos")
   l=0
   %cycle
      readline(s)
      length(s)=34
      uno = hex2(s,8)
      %if charno(s, 7) = '-' %or uno<0 %or uno>63 %start
         uno=16_FF; text=" ".s
      %else
         text=" ".pcb(uno)_user." ".s
      %finish
      phex2(uno) %and printline(text) %unless find(text, trace)
      new(l)=text; l=l+1
   %repeat

eof:
   close input
   %for i=0, 1, l-1 %cycle; trace(i)=new(i); %repeat; trace(l)=""
%end

%integer i

set terminal mode(8)
%for i=0, 1, 63 %cycle; trace(i)=""; %repeat
%cycle
   read uno file
   %for i=1,1,10 %cycle
      dump xno file
      wait(500)
   %repeat
%repeat

%endofprogram
