From: "Micha� Morawski" <morawski@zsk.p.lodz.pl>
Subject: Random Access in Ada.Text_IO files
Date: Tue, 11 Feb 2003 19:34:06 +0100
Date: 2003-02-11T19:34:06+01:00 [thread overview]
Message-ID: <b2bg90$c4g$1@atlantis.news.tpi.pl> (raw)
Hi,
I have encountered the following problem
My program (one task) constantly writes some information to the file (log).
This is simple text line produced every 2 seconds.
Sometimes, other task try to analyze the log and the task need to read the
same file.
This works if files are opened in the "shared=" form. But of course both
tasks use different file position pointers. I wrote the simple test program
presented below. If shared is in "no" mode - I receive use_errer, If "yes"
mode, the file "aaaaaaa" is destroyed by Get (Ascii.null is inserted). After
I wrote the simple monitor to separate the operarions I must write either
extension of Ada.Text_IO or own module. In the first case I cannot compile
the module (I receive the message - it is the system module and cannot be
compiled), and my own module have no acces to stream field of File_Type.
Can anyone give me some advice?
procedure TF is
NAZWA_PLIKU : constant String := "aaaaaaa";
task Wr is
end Wr;
task body Wr is
F : File_Type;
ch : Character := 'a';
begin
Create (F, Out_File, NAZWA_PLIKU, "shared=no");
loop
Put (F, ch);
ch := Character'Succ (ch);
if ch > 'z' then
ch := 'a';
end if;
delay 0.01;
end loop;
exception
when others =>
Put_Line ("Blad w zadaniu");
end Wr;
P : File_Type;
ch : Character;
begin
delay 3.0;
Open (P, In_File, NAZWA_PLIKU, "shared=no");
Reset (P);
loop
Get (P, ch);
Put (ch);
delay 0.1;
end loop;
exception
when E : others =>
Put (Ada.Exceptions.Exception_Information (E) &
GNAT.Traceback.Symbolic.Symbolic_Traceback (E));
end TF;
--
Michal Morawski
next reply other threads:[~2003-02-11 18:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-11 18:34 Micha� Morawski [this message]
2003-02-11 18:58 ` Random Access in Ada.Text_IO files Stephen Leake
2003-02-11 21:03 ` Jeffrey Carter
2003-02-12 9:11 ` Egil Harald H�vik
2003-02-12 9:42 ` Egil Harald H�vik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox