uses crt;
type pegawai=record
nip : string[8];
nama: string[20];
gol : string[4];
jumlah: byte;
end;
var
ketemu : boolean;
xnip : string[8];
fpegawai: file of pegawai;
rpegawai: pegawai;
i : byte;
lg : char;
procedure openpegawai;
begin
assign(fpegawai,'c:\pegawai.dat');
{$I-} reset (fpegawai);
{$I+} if ioresult<>0 then rewrite(fpegawai);
end;
begin
openpegawai;
repeat;
clrscr;
gotoxy(10,5);write('nip :');readln(rpegawai.nip);
xnip := rpegawai.nip;
i := 1;
seek(fpegawai,0);ketemu := false;
while not eof(fpegawai) do
begin
seek (fpegawai,i-1);read(fpegawai,rpegawai);
if (rpegawai.nip=xnip) then
begin
ketemu := true;
gotoxy(10,6);write ('Nama :',rpegawai.nama);
gotoxy(10,7);write ('gol :',rpegawai.gol);
gotoxy(10,8);write ('jumlah anak :',rpegawai.jumlah);
gotoxy(10,9);write ('data sudah ada!');readln;
end;
inc(i);
end;
if not ketemu then
begin
RPEGAWAI.NIP := XNIP ;
gotoxy(10,6);write ('Nama :');readln(rpegawai.nama);
gotoxy(10,7);write ('gol :');readln(rpegawai.gol);
gotoxy(10,8);write ('jumlah anak :');readln(rpegawai.jumlah);
seek(fpegawai,filesize(fpegawai));
write(fpegawai,rpegawai);
end;
gotoxy(10,9);write('input lagi[Y/T]:');readln(lg);
until upcase(lg) ='T';
close(fpegawai);
end.
Tidak ada komentar:
Posting Komentar