%begin; !WIR1: read .wir file and output it as a single line
%integerarray b(0:255)
%integerarray ok(0:255)
%integer n=0,i
  %on 9 %start
    newline; selectoutput(0)
    %for i = 0,1,255 %cycle
      n = n+b(i)
      %unless b(i)=0 %start
        write(i,3); space; %if ' '<i<126 %then printsymbol(i) %else space
        write(b(i),6); newline
      %finish
    %repeat
    write(n,0); newline
    %stop
  %finish
  b(i) = 0 %and ok(i) = 0 %for i = 0,1,255
  ok(i) = 1 %for i = '0',1,'9'
  ok('+') = 1; ok('-') = 1; ok(nl) = 1
  ok('X') = 1; ok('Y') = 1; ok('D') = 1; ok('M') = 1
  openinput(1,cliparam); selectinput(1)
  openoutput(1,cliparam); selectoutput(1)
  %cycle
    readsymbol(i)
    b(i) = b(i)+1
    %exitif ok(i)=0
    printsymbol(i) %unless i=nl
  %repeat
  selectoutput(0)
  %cycle
    printsymbol(i); readsymbol(i)
  %repeat
%end
