05/01/12

Program MULTI - LIST pada PASCAL

uses crt;
type
filebio = record
npm:string[8];
nirm:string[3];
nama:string[15];
alamat:string[10];
end;
filenirm = record
nirm2:string[3];
masuk:string[10];
akhir:string[10];
end;
var
biodata :array[1..10] of filebio;
tglnirm :array[1..10] of filenirm;
isi:text;
a,x,y:integer;


Procedure tbio;
begin
a:=5;
assign(isi,'biodata2.dat');
reset(isi);
writeln('Biodata');
writeln('************************************************************');
writeln('* Npm * Nirm * Nama * alamat *');
writeln('************************************************************');
for x:=1 to 10 do
begin
readln(isi,biodata[x].npm);
readln(isi,biodata[x].nirm);
readln(isi,biodata[x].nama);
readln(isi,biodata[x].alamat);
write('* ',biodata[x].npm,' * ',biodata[x].nirm,' * ',biodata[x].nama,' * ',biodata[x].alamat:5);
gotoxy(60,a);
writeln('*');
a:=a+1;
end;
close(isi);
writeln('************************************************************');
readln;
end;

procedure tnirm;
begin
assign(isi,'filenirm.dat');
reset(isi);
writeln('File Nirm');
writeln('*****************************************************');
writeln('* Nirm * Tanggal Masuk * Tanggal Akhir *');
writeln('*****************************************************');
for x := 1 to 10 do
begin
readln(isi,tglnirm[x].nirm2);
readln(isi,tglnirm[x].masuk);
readln(isi,tglnirm[x].akhir);
writeln('* ',tglnirm[x].nirm2,' * ',tglnirm[x].masuk,' * ',tglnirm[x].akhir,' *');
end;
writeln('*****************************************************');
close(isi);
readln;
end;


procedure daftarsiswa;
begin
a:=5;
gotoxy(1,30);writeln('Daftar Siswa');
writeln('***********************************************************************');
writeln('* No * Npm * Nirm * Nama * Tgl masuk * Tgl Akhir *');
writeln('***********************************************************************');
for x := 1 to 10 do
begin
write('* ',x,' * ',biodata[x].npm,' * ',biodata[x].nirm,' * ',biodata[x].nama,' *',' *',' *');
for y := 1 to 10 do
if biodata[x].nirm = tglnirm[y].nirm2 then
begin
gotoxy(46,a);
writeln(tglnirm[y].masuk);
gotoxy(60,a);
writeln(tglnirm[y].akhir);
a:=a+1;
end;
end;
writeln('***********************************************************************');
readln;
end;

begin
clrscr;tbio;
clrscr;tnirm;
clrscr;daftarsiswa;
end.

19/10/11

Program Sortir pada PASCAL

Program output_pascal;
uses crt;
label z;
label l;
var textfile:text;
FileName, TFile : String;
a:array[1..15] of string;
i,j:integer;
x,v:char;
temp: string;

procedure input;
Begin
clrscr;
gotoxy(10,10);Write('Masukkan nama file '+
+'dengan alamat lengkap dari file: ');
readln(FileName);clrscr;
writeln('-------DATA MAHASISWA-----');
writeln('--------------------------');
writeln('KELAS NAMA NPM');
writeln('--------------------------');
writeln;
{A .txt file will be assigned to a text variable}
Assign(textfile, 'd:\input.TXT');
Reset(textfile); {'Reset(x)' - means open the file x}
Repeat
Readln(textfile,TFile);
Writeln(TFile);
Until Eof(textfile);
Close(textfile);
Readln;
End;

procedure sort;
begin
clrscr;
assign(textfile,'d:\input.TXT');
reset(textfile);
for i:=1 to 15 do readln(textfile,a[i]);
close(textfile);



for i:=1 to 14 do
for j:=i to 15 do
if a[j] begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;end;

assign(textfile,'d:\input.TXT');
rewrite(textfile);
for i:=1 to 15 do writeln(textfile,a[i]);
close(textfile);
end;


procedure output;
Begin
clrscr;
gotoxy(4,5);Write('Masukkan nama file ');
gotoxy(4,6);write('(dengan alamat file lengkap) of the text file: ');
readln(FileName);
gotoxy(10,8);write('-------DATA MAHASISWA-----');
gotoxy(10,9);write('--------------------------');
gotoxy(10,10);write('KELAS NAMA NPM');
gotoxy(10,11);write('--------------------------');
{A .txt file will be assigned to a text variable}
Assign(textfile, 'd:\input.txt');
Reset(textfile); {'Reset(x)' - means open the file x}
Repeat
Readln(textfile,TFile);
Writeln(TFile);
Until Eof(textfile);
Close(textfile);
Readln;
End;

begin
z: clrscr;
gotoxy(20,8);write('-----------------------');
gotoxy(20,9);write('| Program Sorting |');
gotoxy(20,10);write('-----------------------');
gotoxy(20,11);write('|1.Masukkan Data |');
gotoxy(20,12);write('|2.Sortir Data |');
gotoxy(20,13);write('|3.Output |');
gotoxy(20,14);write('|4.Exit Menu |');
gotoxy(20,15);write(' Masukkan (1,2,3,4) : ');readln(x);

case x of
'1' : input;
'2' : sort;
'3' : output;
'4' : goto l;
end;

if x = '2' then
begin
clrscr;
writeln('Selesai(tekan Enter)');
writeln('this wait...'); readln;
goto z;
end;
writeln('Apakah anda ingin kembali ke menu? :{y/t} '); readln(v);
if (v = 'y') or (v = 'Y') then goto z;

l: end.