Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.52 KB | None | 0 0
  1. program LR_16;
  2. uses crt;
  3. type
  4. AbonRec=record
  5.               fam:string[20];
  6.               fio:string[50];
  7.               tel:string[10];
  8.               end;
  9. TypeFile=file of AbonRec;
  10.  
  11. var
  12.     f1:TypeFile;
  13.     s:abonrec;
  14.     f:TypeFile;
  15.     isearch:string;
  16.     nf:string;
  17.  
  18. procedure file_cr(nf:string);
  19. begin
  20.     assign(f,nf);
  21.     rewrite((F));
  22.     with s do begin
  23.     writeln('Окончание ввода - #...');
  24.     repeat
  25.     write('Введите фамилию абонента: ');
  26.     readln(Fam);
  27.     if fam<>'#' then begin
  28.     write('Введите инициалы: ');
  29.     readln(fio);
  30.     write('Введите номер телефона абонента: ');
  31.     readln(Tel);
  32.     writeln;
  33.     write(f,s);end;
  34.     until fam='#';
  35.     end;
  36.     close((F));
  37. end;
  38.  
  39. Procedure file_search(isearch:string);
  40. Begin
  41.     assign(f,nf);
  42.     reset((F));
  43.     with s do begin
  44.     while not eof((F)) do begin
  45.     read(f,s);
  46.     if s.fam=isearch then begin
  47.     writeln;
  48.     write('Номер телефона абонента ',s.fam,' - ',s.tel);end;
  49.     end;
  50.     end;
  51. end;
  52.  
  53. procedure OKNO(x1,y1,x2,y2,c1,c2:integer);
  54. begin
  55.     textbackground(0);clrscr;
  56.     textbackground(c1);
  57.     textcolor(c2);
  58.     window(x1,y1,x2,y2);clrscr;
  59.     clrscr;
  60. end;
  61.  
  62. function okfile(fl:string):boolean;
  63. begin
  64.     {$I-}
  65.     okfile:=false;
  66.     assign(f1,fl);
  67.     reset(f1);close(f1);
  68.     {$I+}
  69.     if ioresult=0 then okfile:=true;
  70. end;
  71.  
  72. begin
  73.     OKNO(5,5,55,21,124,255);
  74.     nf:='С:/f1.txt';
  75.     writeln('Введите фамилию: ');
  76.     readln(isearch);
  77.     if not okfile(nf) then
  78.     file_cr(nf);
  79.     file_search(isearch);
  80.     readln;
  81. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement