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 : December 4, 1989.
12-- author : Michael Nobles.
13
14-- current_file_p.adb
15
16
17package body Current_File_P is
18
19 procedure Create_File(DataN : in out Pointer_String) is
20
21 begin
22 Dir_IO.Create(Data_FP,
23 Dir_IO.InOut_File,
24 DataN.all);
25 end Create_File;
26
27 procedure Change_File(DataN : in out Pointer_String;
28 Time : in Integer) is
29 Filename_OK : Boolean := False;
30
31 L : Integer;
32
33 Choice : Character;
34
35 Filename : String(1..20);
36
37 Dummy : String(1..20);
38 begin
39 if Time > 1 then
40 Dir_IO.Close(Data_FP);
41 Ada.Text_IO.Get_Line(Dummy,L);
42 end if;
43
44 while not Filename_OK
45 loop
46 begin
47 Fix_Cursor(2,5);
48 Ada.Text_IO.Put("Current Data Filename : ");
49 Ada.Text_IO.Get_Line(Filename,L);
50 DataN := new String'(Filename(1..L));
51
52 Dir_IO.Open(Data_FP,Dir_IO.InOut_FILE,DataN.all);
53 Filename_OK := True;
54 exception when Dir_IO.NAME_ERROR =>
55 Fix_Cursor(3,5);
56 Ada.Text_IO.Put("New Data File. Create(y/n) ? ");
57 Ada.Text_IO.Get(Choice);
58 if(Choice = 'y' or Choice = 'Y') then
59 Create_File(DataN);
60 Filename_OK := True;
61 else
62 Filename_OK := False;
63 end if;
64 Ada.Text_IO.Get_Line(Dummy,L);
65 Fix_Cursor(3,5);
66 Ada.Text_IO.Put(" ");
67 end;
68 end loop;
69 end Change_File;
70
71end Current_File_P;