Yurttas/PL/IL/Ada-95/F/03/01/02/00/case e 10.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-- purpose : to demonstrate using case selection statement
15-- with Enumerated choices.
16
17-- case_e_10.adb
18
19
20with Ada.Text_IO;
21use Ada.Text_IO;
22
23procedure Case_E_10 is
24
25 type First_Last is (First, Last);
26
27 package E_IO is new Enumeration_IO(First_Last);
28 use E_IO;
29
30 subtype S_5 is String(1..5);
31
32 T : S_5;
33
34 L : Integer;
35
36 F_L : First_Last;
37
38begin
39
40 Put("--> First : "); New_Line;
41 Put(" or Last : ");
42
43 Get_line(T,L);
44 Skip_Line;
45
46 if T(1..L) = "First" then
47 F_L := First;
48 else
49 F_L := Last;
50 end if;
51
52 case F_L is
53 when First => Put("First - ");
54 Put(F_L);
55 New_Line;
56 when Last => Put("Last - ");
57 Put(F_L);
58 New_Line;
59 end case;
60
61end Case_E_10;