1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301 | package body Dual_IO is
Log_open : Boolean := False;
Log_text : Ada.Text_IO.File_Type;
procedure Check_Log is
begin
if not Log_open then raise Log_not_open; end if;
end Check_Log;
procedure Create_Log (Name : in String) is
begin
if Log_open then raise Log_already_open; end if;
Ada.Text_IO.Create (File => Log_text,
Mode => Ada.Text_IO.Out_File,
Name => Name);
Log_open := True;
end Create_Log;
procedure Append_Log (Name : in String) is
begin
if Log_open then raise Log_already_open; end if;
Ada.Text_IO.Open (File => Log_text,
Mode => Ada.Text_IO.Append_File,
Name => Name);
Log_open := True;
end Append_Log;
procedure Close_Log is
begin
Check_Log;
Ada.Text_IO.Close (Log_text);
Log_open := False;
end Close_Log;
function Is_Log_Open return Boolean is
begin
return Log_open;
end Is_Log_Open;
procedure Close_and_Append_Log is
log_name : constant String := Ada.Text_IO.Name (Log_text);
begin
Close_Log;
Append_Log (log_name);
end Close_and_Append_Log;
procedure Flush is
begin
Ada.Text_IO.Flush;
Check_Log;
Ada.Text_IO.Flush (Log_text);
end Flush;
procedure New_Line (Spacing : in Positive_Count := 1) is
begin
Ada.Text_IO.New_Line (Spacing);
Check_Log;
Ada.Text_IO.New_Line (Log_text, Spacing);
end New_Line;
procedure Skip_Line (Spacing : in Positive_Count := 1) is
begin
Ada.Text_IO.Skip_Line (Spacing); -- *in* Standard
Check_Log;
Ada.Text_IO.New_Line (Log_text, Spacing); -- *out* Log
end Skip_Line;
procedure New_Page is
begin
Ada.Text_IO.New_Page;
Check_Log;
Ada.Text_IO.New_Page (Log_text);
end New_Page;
procedure Skip_Page is
begin
Ada.Text_IO.Skip_Page; -- *in* Standard
Check_Log;
Ada.Text_IO.New_Page (Log_text); -- *out* Log
end Skip_Page;
-----------------------------
-- Characters Input-Output --
-----------------------------
procedure Get (Item : out Character) is
C : Character;
begin
Ada.Text_IO.Get (C); -- *in* Standard
Check_Log;
Ada.Text_IO.Put (Log_text, C); -- *out* Log
Item := C;
end Get;
procedure Put (Item : in Character) is
begin
Ada.Text_IO.Put (Item);
Check_Log;
Ada.Text_IO.Put (Log_text, Item);
end Put;
--------------------------
-- Strings Input-Output --
--------------------------
procedure Get (Item : out String) is
S : String (Item'Range);
begin
Ada.Text_IO.Get (S); -- *in* Standard
Check_Log;
Ada.Text_IO.Put (Log_text, S); -- *out* Log
Item := S;
end Get;
procedure Put (Item : in String) is
begin
Ada.Text_IO.Put (Item);
Check_Log;
Ada.Text_IO.Put (Log_text, Item);
end Put;
procedure Get_Line
(Item : out String;
Last : out Natural) is
S : String (Item'Range);
L : Natural;
begin
Ada.Text_IO.Get_Line (S, L); -- *in* Standard
Check_Log;
Ada.Text_IO.Put_Line (Log_text, S (1 .. L)); -- *out* Log
Item (Item'First .. Item'First + L - 1) := S (1 .. L);
Last := L;
end Get_Line;
procedure Put_Line
(Item : in String) is
begin
Ada.Text_IO.Put_Line (Item);
Check_Log;
Ada.Text_IO.Put_Line (Log_text, Item);
end Put_Line;
package body Integer_IO is
package TIIO is new Ada.Text_IO.Integer_IO (Num);
procedure Get (Item : out Num;
Width : in Field := 0) is
I : Num;
begin
TIIO.Get (I, Width); -- *in* Standard
Check_Log;
TIIO.Put (Log_text, I, Width); -- *out* Log
Item := I;
end Get;
procedure Put (Item : in Num;
Width : in Field := Default_Width;
Base : in Number_Base := Default_Base) is
begin
TIIO.Put (Item, Width, Base);
Check_Log;
TIIO.Put (Log_text, Item, Width, Base);
end Put;
end Integer_IO;
package body Float_IO is
package TFIO is new Ada.Text_IO.Float_IO (Num);
procedure Get (Item : out Num;
Width : in Field := 0) is
I : Num;
begin
TFIO.Get (I, Width); -- *in* Standard
Check_Log;
TFIO.Put (Log_text, I); -- *out* Log
Item := I;
end Get;
procedure Put (Item : in Num;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp) is
begin
TFIO.Put (Item, Fore, Aft, Exp);
Check_Log;
TFIO.Put (Log_text, Item, Fore, Aft, Exp);
end Put;
end Float_IO;
package body Fixed_IO is
package TXIO is new Ada.Text_IO.Fixed_IO (Num);
procedure Get (Item : out Num;
Width : in Field := 0) is
I : Num;
begin
TXIO.Get (I, Width); -- *in* Standard
Check_Log;
TXIO.Put (Log_text, I); -- *out* Log
Item := I;
end Get;
procedure Put (Item : in Num;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp) is
begin
TXIO.Put (Item, Fore, Aft, Exp);
Check_Log;
TXIO.Put (Log_text, Item, Fore, Aft, Exp);
end Put;
end Fixed_IO;
package body Decimal_IO is
package TDIO is new Ada.Text_IO.Decimal_IO (Num);
procedure Get
(Item : out Num;
Width : in Field := 0) is
I : Num;
begin
TDIO.Get (I, Width); -- *in* Standard
Check_Log;
TDIO.Put (Log_text, I); -- *out* Log
Item := I;
end Get;
procedure Put
(Item : in Num;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp) is
begin
TDIO.Put (Item, Fore, Aft, Exp);
Check_Log;
TDIO.Put (Log_text, Item, Fore, Aft, Exp);
end Put;
end Decimal_IO;
package body Modular_IO is
package TMIO is new Ada.Text_IO.Modular_IO (Num);
procedure Get
(Item : out Num;
Width : in Field := 0) is
I : Num;
begin
TMIO.Get (I, Width); -- *in* Standard
Check_Log;
TMIO.Put (Log_text, I, Width); -- *out* Log
Item := I;
end Get;
procedure Put
(Item : in Num;
Width : in Field := Default_Width;
Base : in Number_Base := Default_Base) is
begin
TMIO.Put (Item, Width, Base);
Check_Log;
TMIO.Put (Log_text, Item, Width, Base);
end Put;
end Modular_IO;
package body Enumeration_IO is
package TEIO is new Ada.Text_IO.Enumeration_IO (Enum);
procedure Get (Item : out Enum) is
I : Enum;
begin
TEIO.Get (I); -- *in* Standard
Check_Log;
TEIO.Put (Log_text, I); -- *out* Log
Item := I;
end Get;
procedure Put (Item : in Enum;
Width : in Field := Default_Width;
Set : in Type_Set := Default_Setting) is
begin
TEIO.Put (Item, Width, Set);
Check_Log;
TEIO.Put (Log_text, Item, Width, Set);
end Put;
end Enumeration_IO;
end Dual_IO;
|