Yurttas/PL/IL/Ada-95/F/05/01/00/sequential file processing p.adb

From ZCubes Wiki
Revision as of 05:44, 5 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="ada" line start="1" enclose="div">-- -- Copyright(C) 1998 -- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. -- -- Permis...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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-- sequential_file_processing_p.adb
 15
 16
 17package body Sequential_File_Processing_P is
 18
 19  procedure Get_File_Names(File_Names      : out List_File_Names;
 20                           Number_of_Files : out Integer) is
 21
 22    M : constant Integer := 32;
 23
 24    subtype String_M is String(1..M);
 25
 26    File_Name : String_M;
 27
 28    N,
 29    L  : Integer;
 30
 31  begin
 32
 33    Put_Line("========================");
 34    Put_Line("=    Name the Files    =");
 35    Put_Line("========================");
 36    New_Line(2); 
 37
 38    Put("  Number_of_Files : ");
 39    Get(N);
 40    Skip_Line;
 41
 42    New_Line(2); 
 43
 44    for I in 1..N
 45    loop
 46      Put("File-Name-");
 47      Put(I, Width => 0);
 48      Put(" : ");
 49      Get_Line(File_Name,L);
 50      File_Names(I) := new String'(File_Name(1..L));
 51    end loop;
 52    Number_of_Files := N;
 53
 54  end Get_File_Names;
 55
 56  procedure Create_Sequential_File(In_File_Name,
 57                                   Out_File_Name : in Access_String) is
 58
 59    In_File_P  : File_Type;
 60    Out_File_P : Seq_IO.File_Type;
 61
 62    R0 : Data_Record;
 63
 64  begin
 65
 66    Open(In_File_P,In_File,In_File_Name.all);
 67
 68    Seq_IO.Create(Out_File_P,Seq_IO.Out_File,Out_File_Name.all);
 69
 70    while not End_Of_File(In_File_P) 
 71    loop
 72      Get(In_File_P,R0.F0);
 73      Get(In_File_P,R0.F1);
 74      Get(In_File_P,R0.F2);
 75      Skip_Line(In_File_P);
 76
 77      Seq_IO.Write(Out_File_P,R0);
 78    end loop;
 79
 80    Close(In_File_P);
 81    Seq_IO.Close(Out_File_P);
 82
 83  end Create_Sequential_File;
 84
 85  procedure View_Sequential_File(In_File_Name,
 86                                 Out_File_Name : in Access_String) is
 87
 88    In_File_P  : Seq_IO.File_Type;
 89    Out_File_P : File_Type;
 90
 91    R0 : Data_Record;
 92
 93  begin
 94
 95    Seq_IO.Open(In_File_P,Seq_IO.In_File,In_File_Name.all);
 96
 97    Create(Out_File_P,Out_File,Out_File_Name.all);
 98
 99    Put_Line(Out_File_P,"from Sequential_File to Text_File /");
100    New_Line(Out_File_P);
101
102    while not Seq_IO.End_Of_File(In_File_P) 
103    loop
104      Seq_IO.Read(In_File_P,R0);
105
106      Put(Out_File_P,R0.F0);
107      Put(Out_File_P,R0.F1);
108      Put(Out_File_P,R0.F2); 
109
110      New_Line(Out_File_P);
111    end loop;
112
113    New_Line(Out_File_P);
114
115    Seq_IO.Close(In_File_P);
116    Close(Out_File_P);
117
118  end View_Sequential_File;
119
120end Sequential_File_Processing_P;