Disaat para IT berlomba-lomba mempelajari PHP, SQL, Oracle, Android, Java, atau minimal Linux.. gw malah masih dibikin pusing dengan program taun 60-an yang amat sangat jadul.
huff.. tapi kalo program sederhana kaya gini aja udah pusing gimana program” besar di perusahaan ya? ckck
huff.. tapi kalo program sederhana kaya gini aja udah pusing gimana program” besar di perusahaan ya? ckck
ok langsung aja, dibawah ini adalah program sortir data yang telah gw buat.
coding :
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;
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;
Writeln(‘Enter the file name ‘+
+’(with its full path) of the text file:’);
readln(FileName);
writeln(‘——-DATA MAHASISWA—–’);
writeln(‘————————–’);
writeln(‘KELAS NAMA NPM’);
writeln(‘————————–’);
{A .txt file will be assigned to a text variable}
Assign(textfile, ‘a:\data45.txt’);
Reset(textfile); {‘Reset(x)’ – means open the file x}
Repeat
Readln(textfile,TFile);
Writeln(TFile);
Until Eof(textfile);
Close(textfile);
Readln;
End;
Begin
clrscr;
Writeln(‘Enter the file name ‘+
+’(with its full path) of the text file:’);
readln(FileName);
writeln(‘——-DATA MAHASISWA—–’);
writeln(‘————————–’);
writeln(‘KELAS NAMA NPM’);
writeln(‘————————–’);
{A .txt file will be assigned to a text variable}
Assign(textfile, ‘a:\data45.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,’a:\data45.TXT’);
reset(textfile);
for i:=1 to 15 do readln(textfile,a[i]);
close(textfile);
begin
clrscr;
assign(textfile,’a:\data45.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]<a[i] then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;
for j:=i to 15 do
if a[j]<a[i] then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;
assign(textfile,’a:\data46.TXT’);
rewrite(textfile);
for i:=1 to 15 do writeln(textfile,a[i]);
close(textfile);
end;
rewrite(textfile);
for i:=1 to 15 do writeln(textfile,a[i]);
close(textfile);
end;
procedure output;
Begin
clrscr;
Writeln(‘Enter the file name ‘+
+’(with its full path) of the text file:’);
readln(FileName);
writeln(‘——-DATA MAHASISWA—–’);
writeln(‘————————–’);
writeln(‘KELAS NAMA NPM’);
writeln(‘————————–’);
{A .txt file will be assigned to a text variable}
Assign(textfile, ‘a:\data46.txt’);
Reset(textfile); {‘Reset(x)’ – means open the file x}
Repeat
Readln(textfile,TFile);
Writeln(TFile);
Until Eof(textfile);
Close(textfile);
Readln;
End;
Begin
clrscr;
Writeln(‘Enter the file name ‘+
+’(with its full path) of the text file:’);
readln(FileName);
writeln(‘——-DATA MAHASISWA—–’);
writeln(‘————————–’);
writeln(‘KELAS NAMA NPM’);
writeln(‘————————–’);
{A .txt file will be assigned to a text variable}
Assign(textfile, ‘a:\data46.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;
writeln(‘——————-’);
writeln(‘Program Sorting’);
writeln(‘——————-’);
writeln(’1.Masukkan Data’);
writeln(’2.Sortir Data’);
writeln(’3.Output’);
writeln(’4.Exit Menu’);
writeln(‘Masukkan (1,2,3,4) : ‘);readln(x);
z: clrscr;
writeln(‘——————-’);
writeln(‘Program Sorting’);
writeln(‘——————-’);
writeln(’1.Masukkan Data’);
writeln(’2.Sortir Data’);
writeln(’3.Output’);
writeln(’4.Exit Menu’);
writeln(‘Masukkan (1,2,3,4) : ‘);readln(x);
case x of
’1′ : input;
’2′ : sort;
’3′ : output;
’4′ : goto l;
end;
’1′ : input;
’2′ : sort;
’3′ : output;
’4′ : goto l;
end;
if x = ’2′ then
begin
clrscr;
writeln(‘Selesai(tekan Enter)’); readln;
goto z;
end;
writeln(‘Apakah anda ingin kembali ke menu? : ‘); readln(v);
if (v = ‘y’) or (v = ‘Y’) then goto z;
begin
clrscr;
writeln(‘Selesai(tekan Enter)’); readln;
goto z;
end;
writeln(‘Apakah anda ingin kembali ke menu? : ‘); readln(v);
if (v = ‘y’) or (v = ‘Y’) then goto z;
l: end.
Keterangan :
- buat datanya dulu di filetext/notepad lalu simpan di direktory c atau d atau lainnya tanpa dimasukan ke dalam folder.
- buat datanya dulu di filetext/notepad lalu simpan di direktory c atau d atau lainnya tanpa dimasukan ke dalam folder.
- pada syntaks diatas, tiap coding untuk menginput data (Assign(textfile, ‘a:\data46.txt’);) diganti menjadi tempat dimana data tersimpan .
cth : Assign(textfile, ‘a:\data45.txt’); => Assign(textfile, ‘c:\data88.txt’);
cth : Assign(textfile, ‘a:\data45.txt’); => Assign(textfile, ‘c:\data88.txt’);
- untuk syntaks pada procedure output, coding ( Assign(textfile, ‘c:\data88.txt’); ) diubah kembali sesuai dimana output tersebut akan disimpan. (jangan disamakan dengan file input)
cth : Assign(textfile, ‘a:\data46.txt’); => Assign(textfile, ‘c:\data89.txt’);
hasilnya : (klik untuk memperbesar)
input :
Output :
kalo ada yang kurang atau tau cara mengembangin programnya lagi tolong di comment ya ^_^
kelas : 2db01