comp.lang.ada
 help / color / mirror / Atom feed
From: Blady <p.p11@orange.fr>
Subject: Re: Ada.Text_IO.File_Type object with user defined Get and Put subprograms.
Date: Fri, 31 Jul 2020 19:06:41 +0200	[thread overview]
Message-ID: <rg1j2v$din$1@gioia.aioe.org> (raw)
In-Reply-To: rfvfda$a0f$1@dont-email.me

Le 30/07/2020 à 23:51, J-P. Rosen a écrit :
> Le 30/07/2020 à 22:21, Blady a écrit :
> 
>> Given a legacy code calling many Put_Line from Ada.Text_IO which works
>> nice in a Terminal, I want to add a mode which sends these outputs to
>> another process without changing the legacy code too much.
>> And I want to keep the Terminal mode.
>>
>> Is there a way to create a File_Type object (from Ada.Text_IO) which
>> would have user defined Get and Put subprograms instead of the
>> predefined ones of the file system?
>>
>> Thus in my case, I will create a custom File_Type object My_Output with
>> the user define Put which will send the lines to the other process and
>> then I will call "Set_Output (My_Ouput);" before the legacy code.
>>
> Why don't you simply pipe the first process to the second one?

Yes, it was an option.
But I have to catch the outputs during some specific execution phases 
and on some particular output values.
Both processes should then have an extra synchronization path which is 
too far for the considered changes.

The simplest solution (I found) is to add a virtual dummy Text_IO 
package (name My_TIO) with Put_Line defined inside processing the values 
and sending the lines to the other process if needed.
And I replaced everywhere with "Ada.Text_IO;" by "with My_TIO;".
But Text_IO is also used for file management inside the legacy code 
which made me going to wrap all the Text_IO stuff :-(

Then I went to think of the possibility of user defined Put and Get 
subprograms for a Text_IO File_Type object.
However, I even don't know if it is feasible on an Unix-Like OS but I 
would be pleased to having this possibility in an Ada way.

Pascal.


  reply	other threads:[~2020-07-31 17:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 20:21 Ada.Text_IO.File_Type object with user defined Get and Put subprograms Blady
2020-07-30 21:51 ` J-P. Rosen
2020-07-31 17:06   ` Blady [this message]
2020-08-01  5:35     ` J-P. Rosen
2020-08-01  7:42       ` Blady
2020-08-01 13:45         ` J-P. Rosen
2020-07-31 18:19 ` Shark8
2020-08-01  7:46   ` Blady
2020-08-01 17:23     ` Shark8
2020-09-04 10:14 ` liyan white
2020-09-24  4:10 ` nimaopatel121
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox