%include "inc:util.imp"
%begin; !Zread

%constinteger max = 65536*3
%bytearray b(1:max)
%string(255)file
%integer k,n=0,pos=0

%on 9 %start
  %stop
%finish

%routine buffer up(%integer k)
  pos = pos+1; b(pos) = k
%end

file = cliparam
file = substring(file,2,length(file)) %if charno(file,1)='/'
openoutput(1,file)
selectoutput(0); printsymbol(15)
prompt(""); set terminalmode(noecho!notermecho)
%cycle
  readsymbol(k) %until k='S'
  bufferup(k)
  readsymbol(n)
  bufferup(n)
  %cycle
    readsymbol(k); bufferup(k)
  %repeatuntil k<' '
%repeatuntil n='9'
selectoutput(1)
%for n = 1,1,pos %cycle
  k = b(n)
  %if k<' ' %then newline %else printsymbol(k)
%repeat

%end
