Yurttas/PL/IL/Ada-95/F/05/00/C/io list character 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 
12-- date   : January 1, 1998.
13-- author : Salih Yurttas.
14
15-- io_list_character_p.adb
16
17
18package body IO_List_Character_P is
19
20  procedure Get_List_Character(N : out Integer;
21                               A : out List_Character) is
22    File_Name : String(1..16);
23    Length    : Integer;
24    In_Data   : File_Type;
25
26    K : Integer := 0;
27  begin
28
29    loop 
30      begin
31        New_Line;
32        Put("--> In_Name: ");
33        Get_Line(File_Name,Length);
34        Open(In_Data,In_File,File_Name(1..Length));
35        exit;
36      exception
37        when NAME_ERROR => Put_Line("Try again...");
38      end;
39    end loop;
40
41    while not End_of_File(In_Data)
42    loop
43      K := K + 1;
44      Get(In_Data,A(K));
45    end loop;
46
47    N := K;
48
49    Close(In_Data);
50
51  end Get_List_Character;
52
53  procedure Put_List_Character(N          : in Integer;
54                               A          : in List_Character;
55                               PageHeader : in String) is
56
57    File_Name : String(1..16);
58    Length    : Integer;
59    Out_Data  : File_Type;
60  begin
61
62    New_Line;
63    Put("--> Out_Name: ");
64    Get_Line(File_Name,Length);
65    Create(Out_Data,Out_File,File_Name(1..Length));
66
67    New_Line(Out_Data);
68    Put(Out_Data,PageHeader);
69    New_Line(Out_Data);
70    for I in 1..N
71    loop
72      Put(Out_Data,A(I)); 
73      New_Line(Out_Data);
74    end loop;
75
76    Close(Out_Data);
77
78  end Put_List_Character;
79
80end IO_List_Character_P;