contoh program file produk.dat

Uses crt;

Type produk=record

Kode:string[4];

Jumlah:longint;

End;

Var

Fpro:file of produk;

Rpro:produk;

Lg:char;

Pil,i:integer;

Nama:string[20];

Total,harga:longint;

Procedure openproduk;

Begin

Assign(fpro,’D:\produk.dat’);

{$I-}  reset (fpro);

{$I+} if Ioresult<>0 then  rewrite (fpro);

End;

Procedure input;

Begin

Open produk;

Repeat

Clrscr;

Gotoxy(30,5); write(‘input data produk’);

Gotoxy(30,6); write(‘————————-‘)

Gotoxy(30,7);  write(‘kode:’);  readln(rpro.kode);

Gotoxy(30,9); write(‘jumlah:’); readln(rpro.jumlah);

Gotoxy(30,10); write(‘———————————‘);

Gotoxy(30,11); write(‘input lagi [Y/T]:’); readln(lg);

Seek (fpro, filesize (fpro));

Write(fpro,rpro);

Until upcase(lg)=’T’;

Close(fpro);

End;

Prosedure output;

Begin

OpenProduk ;

i :=1 ;

clrscr ;

Gotoxy(2, 2) ; Write(‘Informasi PRODUK’) ;

Gotoxy(2, 3) ; Write(‘————————————-‘) ;

Gotoxy(2, 4) ; Write(‘ No  Kode   Nama            Hargajmlh totharga ‘) ;

Gotoxy(2, 5) ; Write(‘————————————-‘) ;

seek(fpro, 0) ;

while not eof(fpro) do

begin

seek(fpro, i-1) ; read(fpro, rpro) ;

if rpro.kode=’T010’then

begin

nama:=’DVD’; harga:=650000;

end

else if rpro.koe=’T011’ then

begin

nama:=’TV’; harga:=’10000000’;

end

else if rpro.kode=’T012’then

begin

nama:=’AC’; harga:=’1250000’;

end;

total:=harga*rpro.jumlah;

Gotoxy(4,5+i) ; Write( i);

Gotoxy(6,5+i) ; Write( rpro.Kode ) ;

Gotoxy(12,5+i) ; Write( Nama)  ;

Gotoxy(27,5+i) ; Write( Harga:8) ;

Gotoxy(35,5+i); write(rpro.jumlah:3);

Gotoxy(43,5+i); write(total:8);

inc (i) ;

end;

Gotoxy(2,5+i) ; Write(‘————————————-‘) ;

Gotoxy(2,6+i) ; Write(‘press any key to continue…’) ;

Close(fPro) ;

Repeat Until Keypressed;

End;

Proceure menu;

Begin

Clrscr;

Gotoxy(5,3); write(‘________________’);

Gotoxy(5,4); write(‘menu utama’);

Gotoxy(5,5); write(‘________________’);

Gotoxy(5,6); write(‘1.input produk’);

Gotoxy(5,7); write(‘2.output produk);

Gotoxy(5,8); write(‘3.keluar’);

Gotoxy(5,9); write(‘________________’);

Gotoxy(5,10); write(‘pilihan:’); readln(pil);

End;

Begin

Pil:=0;

While pil<>3 do

Begin

Menu;

Case pil ofs

1:input;

2:output;

End;

End;

End.

 

 

About boruhasibuan

sabar, berjuang, dan semangat yg disertai kemauan dan do'a dlm menghadapi sgala sesuatu hal, ini-lah yg selalu ada dlm pikiran-Q, berjuang dan berjuang!!!!
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s