Program
filee;
Uses
Crt;
Var
tes : Text;
nama,nim : String;
no,shift,pilih,i : byte;
Tanya : Char;
Begin
Repeat
ClrScr;
Writeln(' Program File Text
Sederhana');
Writeln('
------------------------------');
Writeln(' 1. Masukan Data Anda');
Writeln(' 2. Lihat Data');
Writeln(' 3. Hapus Data');
Writeln(' 4. Keluar');
Writeln('
------------------------------');
Write(' Pilihan Anda :
');Readln(Pilih);
Case Pilih Of
1 : Begin clrscr;
Assign(tes,'praktikum.txt');
rewrite(tes);
Repeat
inc(i);
writeln(' Data - ',i);
writeln('
-------------------------------------');
write(' Nama : '); readln(nama); writeln(tes,nama);
write(' NIM : '); readln(nim); writeln(tes,nim);
write(' Shift : '); readln(shift);writeln(tes,shift);
write(' No. Meja : ');
readln(no); writeln(tes,no);
writeln(tes,' ');
Write(' Memasukan Lagi (Y/T)
: '); readln(tanya);
writeln('
-------------------------------------');
writeln;
Until UpCase(tanya) = 'T';
Close(tes);
End;
2 : Begin clrscr;
Assign(tes,'praktikum.txt');
reset(tes);
i:= 0;
while not eof(tes) do
begin
inc(i);
readln(tes,nama);
readln(tes,nim);
readln(tes,shift); readln(tes,no);
readln(tes);
writeln(' Data -
',i);
writeln('
-------------------------------------');
writeln(' Nama : ',nama);
writeln(' NIM : ',nim);
writeln(' Shift : ',shift);
writeln(' No. Meja :
',no);
writeln('
-------------------------------------');
writeln;
end; readln;
End;
3 : Begin clrscr;
write(' Data akan dihapus
[y/t] : '); readln(tanya);
if upcase (tanya) = 'Y' then
Assign(tes,'praktikum.txt');
erase(tes);
End;
else End;
until
pilih=4;
End.
|
Hasil Output :