Program FileTeman;
Uses Crt;
Var
JenisFile : Text;
Nama : String;
ALamat : String;
Telp : String;
Tanya : Char;
Pilihan : shortint;
Begin
Repeat
ClrScr;
Writeln;
writeln(' ____________________________________');
writeln('| Pilih Salah Satu Menu |');
writeln('|____________________________________|');
writeln('| 1. Membuat File Data Baru |');
writeln('| 2. Memasukkan Data Baru |');
writeln('| 3. Menampilkan Data |');
writeln('| 4. Keluar |');
writeln('|____________________________________|');
writeln('| Masukkan Pilihan : |');
writeln('|____________________________________|');
gotoxy(22,10);Readln(Pilihan);
Case Pilihan Of
1 : Begin
Assign(JenisFile,'Alamat.dat');
ReWrite(JenisFile);
Close(JenisFile);
writeln;
writeln('| File Data Berhasil Dibuat! |');
writeln('|____________________________________|');
readkey;
End;
2 : Begin
Assign(JenisFile,'Alamat.dat');
Append(JenisFile);
Repeat
ClrScr;
Write(' Nama : ');Readln(Nama);
Write(' ALamat : ');Readln(Alamat);
Write(' Telepon : ');Readln(Telp);
Writeln(JenisFile,Nama);
Writeln(JenisFile,Alamat);
Writeln(JenisFile,Telp);
Writeln;
Write('Apakah mau memasukan data lain (Y/T): ');
Tanya := ReadKey;
Until UpCase(Tanya) = 'T';
Close(JenisFile);
Writeln('Data telah dimasukan !');
End;
3 : Begin
Assign(JenisFile,'Alamat.dat');
Reset(JenisFile);
Repeat
Readln(JenisFile,Nama);
Readln(JenisFile,Alamat);
Readln(JenisFile,Telp);
ClrScr;
Writeln(' Nama : ',Nama);
Writeln(' ALamat : ',ALamat);
Writeln(' Telepon : ',Telp);
Writeln;
If Nama = '' Then
Tanya := 'T'
Else
Begin
Write('Apakah melihat data berikut (Y/T) : ');
Tanya := ReadKey;
End;
Until UpCase(Tanya) = 'T';
Close(JenisFile);
End;
Else
End;
Until Pilihan=4;
End.