%begin; !Copy
!Modded JHB 10/12/84: removed FCOMM call & replaced by COPY.
!Modded JGH 24/01/85: uses PAM values rather than always / & to use stream 0
! GDMR 28/06/85: concatenation now works (again?)

%include "inc:util.imp"

%string(255)parm,in,out
%byte sep = '/'

%integer output stream

  %routine copy char by char
  %integer sym
    %on 3,9 %start
        selectoutput(0); printstring(event_message)
        newline %unless event_message=""
        %return
    %finish
    select input (0)
    openinput(1,in) %and selectinput(1) %if in#""
    select output(output stream);  ! GDMR
    %cycle
      readsymbol(sym); printsymbol(sym)
    %repeat
  %end

  %predicate fs can do it
  %integer i,k
    %falseif in="" %or out="" %or charno(in,1)=':' %or charno(out,1)=':'
    %for i = 1,1,length(in) %cycle
      k = charno(in,i)
      %falseif k=','
    %repeat
    %true
  %end

  %onevent 3,4,9 %start
    selectoutput(0); printline(event_message)
    %stop
  %finish

  Select input (0)
  Select output (0)
  sep = PAM_group sep %if pam_group sep >=' '
  parm = cliparam
  %if parm = "" %start
      Prompt ("Input file(s): ")
      read line (in)
      Prompt ("Output file: ")
      read line (out)
      Prompt (":")
  %else
      in = parm %and out = "" %unless parm -> in.(TO STRING(SEP)).out
  %finish

  %if fs can do it %start
    copy(in, out)
  %else
    %if out = "" %start
      output stream = 0
    %else
      open output(1, out)
      output stream = 1
    %finish
    parm = in.","
    copy char by char %while parm -> in.(",").parm
  %finish
%endofprogram
