home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TESTS / LF / COPYFILE.LF < prev    next >
Text File  |  1996-06-04  |  820b  |  17 lines

  1. copy_file(F1,F2) :-
  2.        open_in(F1,S1),         % open the source file,
  3.                                % select it for input;
  4.        open_out(F2,S2),        % open the target file...
  5.        open_out(stdout,S3),    % set the output stream to stdout
  6.        write("Copying from """,F1,""" to """,F2,""" ... "),
  7.        set_output(S2),         % set the output to file #2
  8.        repeat,
  9.        get(X),                 % read a character
  10.        ((X=end_of_file,        % if end of file #1 is reached
  11.          close(S1), close(S2), % then close both files
  12.          write("done."),       % [output reset to stdout]
  13.          !)                    % and cut out the repeat loop
  14.        ;                       % else
  15.         (put(X),               % output the character
  16.          fail)).               % and fail to repeat loop
  17.