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-- purpose : to demonstrate using block for compound statements
15-- with local/global scope.
16
17-- block_01.adb
18
19
20with Ada.Text_IO;
21use Ada.Text_IO;
22
23procedure Block_01 is
24
25 package Int_IO is new Integer_IO(Integer);
26 use Int_IO;
27
28 File_Name : String(1..16);
29
30 Length : Integer;
31
32 In_Data : File_Type;
33
34 K : Integer := 0;
35
36 type List_Integer is array(1..4) of Integer;
37
38 A : List_Integer;
39
40begin
41
42 loop
43 begin
44 Put("--> File_Name: ");
45 Get_Line(File_Name,Length);
46 Open(In_Data,In_File,File_Name(1..Length));
47 exit;
48 exception
49 when NAME_ERROR => Put_Line("Try again...");
50 end;
51 end loop;
52
53 while not End_of_File(In_Data)
54 loop
55 K := K + 1;
56 Get(In_Data,A(K));
57 end loop;
58
59 Close(In_Data);
60
61 Put("--> The number of items counted in given file = ");
62 Put(K);
63
64end Block_01;