{$d+
   test file external binding
   read a message from file bound to fr
   write a message to file bound to fw
}

program tfile( input, output, fr, fw );

const n =  10;

var
   fw : text;
   fr : text;
   f9 : text;
   s  : packed array[1..n] of char;
   c  : char;
   i  : integer;

{ test assign files for eoln termination }
procedure p1;
var   fw1 : text;
begin
   assign(fw1, 'assign.txt');
   rewrite(fw1);
   write( fw1, 'assign test: ***' );
end;

begin
   p1;
   reset( fr ); { NOTE: caller must guarantee this file exists }
   i := 1;
   repeat
      if not eof(fr) then
         read( fr, s[i] )
      else
         s[i] := '?';
      i := i+1;
   until eoln(fr) or (i > n);
   writeln( 'message to tfile was ''', s, '''' );
   rewrite( fw );
   writeln( fw, 'this is a response from tfile' );
   rewrite( f9 );
   rewrite( fr );
   write( fr, 'test line' ); { unterminated line }
end.

{%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end of tfile.pas %%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
