Yurttas/PL/IL/Ada-95/ProgUnits/G/ex 04.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
12-- date : January 1, 1998.
13-- author : Salih Yurttas.
14
15-- purpose : to demonstrate a procedure structure with nested
16-- procedures in Ada-95 programming structuring and
17-- composition.
18
19-- ex_04.adb
20
21
22with Text_IO; use Text_IO;
23
24procedure EX_04 is
25
26 package Int_IO is new Integer_IO(Integer); use Int_IO;
27
28 A : Integer := 1;
29 B : Integer := 5;
30
31 X : Integer := 2;
32 Y : Integer := 8;
33
34 procedure P(H : in String;
35 A,
36 B : in Integer) is
37 begin
38 New_Line;
39 Put_Line(H);
40 Put(A,1);
41 New_Line;
42 Put(B,1);
43 New_Line;
44 end P;
45
46 procedure E(A,
47 B : in out Integer) is
48 T : Integer;
49 begin
50 T := A;
51 A := B;
52 B := T;
53 end E;
54
55begin
56
57 P("A-B before / ", A, B);
58
59 E(A, B);
60
61 P("A-B after / ", A, B);
62
63 E(A, B);
64
65 New_Line;
66
67 P("X-Y before / ", X, Y);
68
69 E(X, Y);
70
71 P("X-Y after / ", X, Y);
72
73 E(X, Y);
74
75end EX_04;