Create File pada Pascal
Ganti tulisan berwarna hijau (E:gaji.dat) sesuai kebutuhan anda, jika program tidak dapat running...
atau download file nya disini...
{ Program File }
{ Copyright By. Muss Mulyadie }
Program File_1;
uses crt;
type
pegawai=record
nip : longint;
nmp : string[20];
gol : byte;
end;
var
rec_peg : pegawai;
file_peg : File of Pegawai;
benar,lagi : char;
pil,no : integer;
gp,totgp : longint;
procedure entry;
begin
assign(file_peg,'E:gaji.dat'); { rancang sebuah file dengan nama gaji.dat }
rewrite(file_peg);
benar:='T';
while upcase(benar)='T' do
begin
clrscr;
with rec_peg do
begin
writeln('ENTRY DATA GAJI');
writeln('<<<<<<<<>>>>>>>');
write('No. Induk Pegawai :');readln(nip);
write('Nama Pegawai :');readln(nmp);
write('Golongan :');readln(gol);
writeln;
end;
write('Data Sudah Benar Y/T :');readln(benar);
end;
write(file_peg,rec_peg);
close(file_peg);
end;
procedure tambah_data;
begin
assign(file_peg,'E:gaji.dat');
reset(file_peg);
if IOresult <> 0 then rewrite(file_peg);
seek(file_peg,filesize(file_peg));
lagi:='Y';
while upcase(lagi)='Y' do
begin
benar:='T';
while upcase(benar)='T' do
begin
clrscr;
with rec_peg do
begin
writeln(' ENTRY DATA GAJI');
writeln('<<<<<<<<<<<<<>>>>>>>>>>>>');
write('No. Induk Pegawai :');readln(nip);
write('Nama Pegawai :');readln(nmp);
write('Golongan :');readln(gol);
writeln;
end;{with}
write('Data Sudah Benar Y/T :');readln(benar);
end;{while benar}
write(file_peg,rec_peg);{rekam data}
write('Masih Ada Data Y/T :');readln(lagi);
end;{while lagi}
close(file_peg);
end;
procedure info;
begin
{Buka data gaji}
assign(file_peg,'E:gaji.dat');
reset(file_peg);
clrscr;
writeln('Daftar Gaji Pegawai PT.OKAJADEH');
writeln('---------------------------------------------');
writeln('No No.Induk Nama Pegawai Gol Gaji Pokok');
writeln('---------------------------------------------');
no:=0;
while not eof(file_peg) do
begin
read(file_peg,rec_peg);
with rec_peg do
begin
if gol=1 then gp:=350000 else if gol=2 then gp:=500000 else gp:=650000;
no:=no+1;
writeln(no,' ',nip,' ',nmp,' ',gol,' ',gp);
totgp:=totgp+gp;
end;
end;
writeln('---------------------------------------------');
writeln('Total Gaji ',totgp);
writeln('---------------------------------------------');
close(file_peg);
readln;
end;
{Program Utama}
begin
repeat
begin
clrscr;
writeln('<< Menu Pilihan >>');
writeln('------------------');
writeln('1.Entry Data');
writeln('2.Tambah Data');
writeln('3.Informasi');
writeln('4.Selesai');
writeln;
write('Pilihan [1..4]:?');readln(pil);
if pil=1 then entry else if pil=2 then tambah_data else
if pil=3 then info else writeln('selesai');
end;
until(pil=4);
end.
atau download file nya disini...
{ Program File }
{ Copyright By. Muss Mulyadie }
Program File_1;
uses crt;
type
pegawai=record
nip : longint;
nmp : string[20];
gol : byte;
end;
var
rec_peg : pegawai;
file_peg : File of Pegawai;
benar,lagi : char;
pil,no : integer;
gp,totgp : longint;
procedure entry;
begin
assign(file_peg,'E:gaji.dat'); { rancang sebuah file dengan nama gaji.dat }
rewrite(file_peg);
benar:='T';
while upcase(benar)='T' do
begin
clrscr;
with rec_peg do
begin
writeln('ENTRY DATA GAJI');
writeln('<<<<<<<<>>>>>>>');
write('No. Induk Pegawai :');readln(nip);
write('Nama Pegawai :');readln(nmp);
write('Golongan :');readln(gol);
writeln;
end;
write('Data Sudah Benar Y/T :');readln(benar);
end;
write(file_peg,rec_peg);
close(file_peg);
end;
procedure tambah_data;
begin
assign(file_peg,'E:gaji.dat');
reset(file_peg);
if IOresult <> 0 then rewrite(file_peg);
seek(file_peg,filesize(file_peg));
lagi:='Y';
while upcase(lagi)='Y' do
begin
benar:='T';
while upcase(benar)='T' do
begin
clrscr;
with rec_peg do
begin
writeln(' ENTRY DATA GAJI');
writeln('<<<<<<<<<<<<<>>>>>>>>>>>>');
write('No. Induk Pegawai :');readln(nip);
write('Nama Pegawai :');readln(nmp);
write('Golongan :');readln(gol);
writeln;
end;{with}
write('Data Sudah Benar Y/T :');readln(benar);
end;{while benar}
write(file_peg,rec_peg);{rekam data}
write('Masih Ada Data Y/T :');readln(lagi);
end;{while lagi}
close(file_peg);
end;
procedure info;
begin
{Buka data gaji}
assign(file_peg,'E:gaji.dat');
reset(file_peg);
clrscr;
writeln('Daftar Gaji Pegawai PT.OKAJADEH');
writeln('---------------------------------------------');
writeln('No No.Induk Nama Pegawai Gol Gaji Pokok');
writeln('---------------------------------------------');
no:=0;
while not eof(file_peg) do
begin
read(file_peg,rec_peg);
with rec_peg do
begin
if gol=1 then gp:=350000 else if gol=2 then gp:=500000 else gp:=650000;
no:=no+1;
writeln(no,' ',nip,' ',nmp,' ',gol,' ',gp);
totgp:=totgp+gp;
end;
end;
writeln('---------------------------------------------');
writeln('Total Gaji ',totgp);
writeln('---------------------------------------------');
close(file_peg);
readln;
end;
{Program Utama}
begin
repeat
begin
clrscr;
writeln('<< Menu Pilihan >>');
writeln('------------------');
writeln('1.Entry Data');
writeln('2.Tambah Data');
writeln('3.Informasi');
writeln('4.Selesai');
writeln;
write('Pilihan [1..4]:?');readln(pil);
if pil=1 then entry else if pil=2 then tambah_data else
if pil=3 then info else writeln('selesai');
end;
until(pil=4);
end.
Comments
Post a Comment
Terimakasih telah berkunjung dan berkomentar disini...