The Ada Program: simple.adb
1 -- simple.adb: simple example of array declarations and access
2
3 procedure Simple is
4
5 -- Array type declarations:
6 -- * index range can be any discrete type
7 -- * lower and upper bound can be arbitrary
8 -- * components can have any type
9
10 type AT1 is array (1..50) of Integer;
11 type AT2 is array (4..457) of Integer;
12 type AT3 is array (0..9) of Boolean;
13 type AT4 is array (0..9) of String(1..5);
14
15 type Complex is
16 record
17 X, Y: Float;
18 end record;
19 type AT5 is array (0..9) of Complex;
20
21 type AT6 is array (1..8) of AT4;
22
23 type AT7 is array (Character range 'A'..'Z') of Float;
24
25 type Color is (Red, Orange, Yellow, Green, Blue, Violet);
26 type AT8 is array (Orange..Blue) of Boolean;
27 type AT9 is array (Color'Range) of Character;
28
29 A:AT1; B:AT2; C:AT3; D:AT4; E:AT5; F:AT6; G:AT7; H:AT8; I:AT9;
30
31 N : constant Integer := 1;
32
33 begin
34
35 A(2*N+5) := 4_567;
36 B(N+4) := 4_567;
37 C(N) := True;
38 D(3*N) := "ABCDE";
39 E(0) := Complex' (X=>6.7, Y=>5.6);
40 F(3) := AT4' (AT4'Range => "XXXXX");
41 F(3)(1)(5) := 'E';
42 G(Character'Succ('E')) := 2.9;
43 H(Color'Pred(Yellow)) := True;
44 I(Red) := 'Q';
45
46 end Simple;