uses wincrt;
type dosen=record
kode :string[3];
nama :string[30];
pendidikan :string[10];
keahlian :string[20];
end;
var
fdsn :file of dosen;
rdsn :dosen;
i :byte;
lg :char;
ketemu :Boolean;
xkode :string[3];
procedure opendosen;
begin
assign (fdsn,'d:\dosen.dat');
{$I-} reset(fdsn);
{$I+}if Ioresult <>0then rewrite(fdsn);
end;
begin
opendosen;
repeat
clrscr;
ketemu :=false;
i:=1; seek(fdsn,0);
gotoxy(10,3);write('kode dosen :');readln(xkode);
while not eof(fdsn) do
begin
seek(fdsn,i-1);read(fdsn,rdsn);
if rdsn.kode= xkode then
begin;
ketemu:=true;
gotoxy(10,5);write('nama :',rdsn.nama);
gotoxy(10,6);write('pendidikan:',rdsn.pendidikan);
gotoxy(10,7);write('keahlian :',rdsn.keahlian);
gotoxy(10,9);write('Data ini sudah ada!');
end;
inc(i);
end;
if not ketemu then
begin
gotoxy(10,11);write('nama :');readln(rdsn.nama);
gotoxy(10,12);write('pendidikan :');readln(rdsn.pendidikan);
gotoxy(10,13);write('keahlian :');readln(rdsn.keahlian);
rdsn.kode:=xkode;
seek (fdsn, filesize(fdsn));
write(fdsn,rdsn);
end;
gotoxy(10,15);write('input lagi[Y/T]:');readln(lg);
until upcase(lg)='T';
close (fdsn);
end.