Yurttas/PL/IL/Ada-95/F/05/00/E/io list enumerate p.adb

From ZCubes Wiki
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_enumerate_p.adb
15
16
17package body IO_List_Enumerate_P is
18
19  package E_IO is new Enumeration_IO(First_Last);
20  use E_IO;
21
22  procedure Get_List_Enumerate(N : out Integer;
23                               A : out List_Enumerate) 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_Enumerate;
54
55  procedure Put_List_Enumerate(N          : in Integer;
56                               A          : in List_Enumerate;
57                               PageHeader : in String) is
58    File_Name : String(1..16);
59    Length    : Integer;
60    Out_Data  : File_Type;
61  begin
62
63    New_Line;
64    Put("--> Out_Name: ");
65    Get_Line(File_Name,Length);
66    Create(Out_Data,Out_File,File_Name(1..Length));
67
68    New_Line(Out_Data);
69    Put(Out_Data,PageHeader);
70    New_Line(Out_Data);
71    for I in 1..N
72    loop
73      Put(Out_Data,A(I)); 
74      New_Line(Out_Data);
75    end loop;
76
77    Close(Out_Data);
78
79  end Put_List_Enumerate;
80
81end IO_List_Enumerate_P;