Sabtu, 16 Juli 2011

M.P.program

uses crt;
type Dosen  =  record
       kode          : string [3];
       nama          : string [40];
       keahlian      : string [20];
      pendidikan  : string [20];
      end;
var
   fdsn         : file of dosen;
   rdsn         : dosen;
   i            : byte;
   xkd          : string [31];
   lg           : char;
   ada          : boolean;
procedure opendosen;
begin
    clrscr;
    assign (fdsn,'c:\dosen.dat');
    {$I-} reset (fdsn);
    {$I+} if IOresult <> 0 then rewrite (fdsn);
end;
begin
    opendosen;
    repeat
         a:=1;
         ada := false;
         gotoxy (3,5); write ('kode:'); readln (xkd);
         seek (fdsn,0);
         while not eof (fdsn) do
         begin
             seek (fdsn, a-1); read (fdsn,rdsn);
             if rdsn.kode = xkd then
             begin
                 gotoxy (10,3); write ('nama: ', rdsn.nama);
             gotoxy (10,4); write ('keahlian :',rdsn.keahlian);
                 gotoxy (10,5); write ('pendidikan : ', rdsn.pendidikan);
                 ada := true;
             end;
                 inc (i);
             end;
             rdsn.kode := xkd  ;
             if not ada then
             begin
                 gotoxy (20,2); write ('nama: '); readln (rdsn.nama);
                 gotoxy (20,3); write ('keahlian: '); readln (rdsn.keahlian);
                 gotoxy (20,4); write ('pendidikan :'); readln (rdsn.pendidikan);
                 seek (fdsn, filesize (fdsn));
                 write (fdsn, rdsn);
             end;
             gotoxy (30,3); write ('input lagi [Y/T]:'); readln (lg);
    until upcase (lg) = 'T';
    close (fdsn);
end.

Tidak ada komentar:

Posting Komentar