10 שיעור 


var f:file of integer;         file buffer  --  f^  put(f),get(f)
    k:integer;
  rewrite(f);
  read(k);                     reset(f);
  while k>0 do                 while not eof(f) do
  begin                        begin
    f^:=k;  put(f);              k:=f^;  write(k);
    read(k)                      get(f)
  end;                         end;
__________________________________________________________________________

assign(f,'a:nums.dat');
read(f,x)    <-->  x:=f^; get(f);
write(f,x)   <-->  f^:=x; put(f);

program FILES;
var end1,end2:boolean;
    num1,num2:integer;
    file1, file2, mrg:file of integer;
begin
  assign(file1,'first.dat');
  assign(file2,'second');
  assign(mrg,'a:result');
  reset(file1);
  reset(file2);
  rewrite(mrg);
  read(file1,num1);  read(file2,num2);
  end1:=false;  end2:=false;
  while not end1 and not end2 do
  begin
    if num1 < num2 then begin
      write(mrg,num1);
      if eof(file1)
        then end1:=true
        else read(file1,num1)
      end
    else begin
      write(mrg,num2);
      if eof(file2)
        then end2:=true
        else read(file2,num2)
      end;
  while not end1 do
  begin
    write(mrg,num1);
    if eof(file1)
      then end1:=true
      else read(file1,num1)
    end;
  while not end2 do
  begin
    write(mrg,num2);
    if eof(file2)
      then end2:=true
      else read(file2,num2)
    end;
  close(int1);  close(int2);  close(mrg)
end.

-----------------------------------------------------------------------------

type STUDENT=record
       name:string[20];
       address:string[30];
       chug:integer;
       shana:char
     end;
var BANOT:file of student;
    GIRLS:array[1..1000] of student;
    cnt:0..1000;
    i:integer;

assign(banot,'a:banot.dat');

rewrite(banot);
for i:=1 to cnt do  write(banot,girls[i]);
close(banot);

assign(banot,'a:banot.dat');
reset(banot);
cnt:=0;
while not eof(banot) do
begin
  cnt:=cnt+1;  read(banot,girls[cnt])
end;
close(banot);

assign(banot,'a:banot.dat');
reset(banot);
cnt:=filesize(banot);
for i:=1 to cnt do  read(banot, girls[i]);
close(banot);
-----------------------------------------------------------------------------
type text=file of char;      cr   lf
write(f,ch);  <--> f^:=ch; put(f);
read(f,ch);   <--> ch:=f^; get(f);
writeln(f);
readln(f)
eoln(f)

var x,y:text;
    c:char;
 reset(x);  rewrite(y);
 while not eof(x) do
 begin
   while not eoln(x) do
   begin   read(x,c); write(y,c)  end;
   readln(x);  writeln(y)
 end;

program insert;
var ch:char;
begin
  while not eof do
  begin
    write('  ');
    while not eoln do
    begin  read(ch);  write(ch)
    end;
    writeln;  readln
  end
end.