uses crt;
type dokter = record
kode : string [3];
nama : string [40];
spesialis:string[20];
end;
var
fdok : file of dokter;
rdok : dokter;
i : byte;
xkd : string[3];
lg : char;
ketemu:boolean;
procedure opendokter;
begin
assign(fdok,'c:\dokter.dat');
{$I-} reset(fdok);
{$I+} if ioresult <>0 then rewrite(fdok);
end;
begin
clrscr;
opendokter;
repeat
i := 1;
ketemu := false;
gotoxy (20,5);write('kode:');readln(xkd);
seek(fdok,0);
while not eof (fdok) do
begin
seek(fdok,i-1);read(fdok,rdok);
if rdok.kode = xkd then
begin
gotoxy (20,6);write('nama: ,rdok.nama');
gotoxy (20,7);write('spesialis: ,rdok.spesialis');
ketemu := true;
end;
inc (i);
end;
rdok.kode := xkd;
if not ketemu then
begin
gotoxy (20,8);write('nama:'); readln (rdok.nama);
gotoxy (20,19);write('spesialis: ');readln (rdok.spesialis);
seek(fdok,filesize(fdok));
end;
gotoxy (20,10);write('input lagi[Y/T]:');readln(lg);
until upcase (lg) = 'T';
close(fdok);
end.
Tidak ada komentar:
Posting Komentar