Yurttas/PL/IL/Ada-95/F/01/PU/03.html
| ada-95 programming language fundamentals | |
| 1. program units and overall structure |
packageunit is composed of two parts: specification and body as follows:
--
-- date : January 1, 2000.
-- author : Salih Yurttas.
-- package body
--
-- minni_p.adb
package body Minimum_of_N_Integers_P is
package Int_IO is new Integer_IO(Integer);
use Int_IO;
procedure Get_Integer_List(K : out Integer;
D : out Integer_List) is
In_File_P : File_Type;
I : Integer := 0;
begin
Open(In_File_P, In_File, "in.txt");
while not End_of_File(In_File_P)
loop
I := I + 1;
Get(In_File_P, D(I));
end loop;
K := I;
Close(In_File_P);
end Get_Integer_List;
procedure Find_Min_of_Integer_List(Min,
J : out Integer;
K : in Integer;
D : in ListI) is
M : Integer;
begin
M := D(1);
J := 1;
for I in 2..K
loop
if D(I)then
M := D(I);
J := I;
end if;
end loop;
Min := M;
end Find_Minimum_of_Integer_List;
procedure Put_Minimum_of_Integer_List(Min,
J : in Integer) is
Out_File_P : File_Type;
begin
Create(Out_File_P, Out_File, "out.txt");
Put(Out_File_P,"D(");
Put(Out_File_P,J,1);
Put(Out_File_P,") = ");
Put(Out_File_P,Min,5);
Put(Out_File_P," is the minimum of the list.");
Close(Out_File_P);
end Put_Minimum_of_Integer_List;
end Minimum_of_N_Integers_P;
<< | >> contents << | >> flow of control
Dr.Salih Yurttas