Yurttas/PL/IL/Ada-95/F/05/00/B/io list boolean p.adb
Jump to navigation
Jump to search
1--
2-- Copyright(C) 1998
3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4--
5-- Permission to use, copy, modify, and distribute this
6-- software and its documentation for EDUCATIONAL purposes
7-- and without fee is hereby granted provided that this
8-- copyright notice appears in all copies.
9--
10
11-- date : January 1, 1998.
12-- author : Salih Yurttas.
13
14-- io_list_boolean_p.adb
15
16
17package body IO_List_Boolean_P is
18
19 package Bool_IO is new Enumeration_IO(Boolean);
20 use Bool_IO;
21
22 procedure Get_List_Boolean(N : out Integer;
23 A : out List_Boolean) is
24 File_Name : String(1..16);
25 Length : Integer;
26 In_Data : File_Type;
27
28 K : Integer := 0;
29 begin
30
31 loop
32 begin
33 New_Line;
34 Put("--> In_Name: ");
35 Get_Line(File_Name,Length);
36 Open(In_Data,In_File,File_Name(1..Length));
37 exit;
38 exception
39 when NAME_ERROR => Put_Line("Try again...");
40 end;
41 end loop;
42
43 while not End_of_File(In_Data)
44 loop
45 K := K + 1;
46 Get(In_Data,A(K));
47 end loop;
48
49 N := K;
50
51 Close(In_Data);
52
53 end Get_List_Boolean;
54
55 procedure Put_List_Boolean(N : in Integer;
56 A : in List_Boolean;
57 PageHeader : in String) is
58
59 File_Name : String(1..16);
60 Length : Integer;
61 Out_Data : File_Type;
62 begin
63
64 New_Line;
65 Put("--> Out_Name: ");
66 Get_Line(File_Name,Length);
67 Create(Out_Data,Out_File,File_Name(1..Length));
68
69 New_Line(Out_Data);
70 Put(Out_Data,PageHeader);
71 New_Line(Out_Data);
72 for I in 1..N
73 loop
74 Put(Out_Data,A(I));
75 New_Line(Out_Data);
76 end loop;
77
78 Close(Out_Data);
79
80 end Put_List_Boolean;
81
82end IO_List_Boolean_P;