From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.2l9/+lLWqSFiMnxrrwvdqA.user.gioia.aioe.org!not-for-mail From: Blady Newsgroups: comp.lang.ada Subject: Re: Ada.Text_IO.File_Type object with user defined Get and Put subprograms. Date: Sat, 1 Aug 2020 09:46:22 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <868e4e17-8624-421d-86bb-64d682a691a9o@googlegroups.com> NNTP-Posting-Host: 2l9/+lLWqSFiMnxrrwvdqA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:59620 List-Id: Le 31/07/2020 à 20:19, Shark8 a écrit : > On Thursday, July 30, 2020 at 2:21:10 PM UTC-6, Blady wrote: >> Hello, >> >> 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? > > Kind of; I have a generic interface-package that I use for dealing with text-io and its permutations. > > I just published it on github: https://github.com/OneWingedShark/EVIL/tree/master/src > It's part of what's intended to be a verified, general purpose library -- though I'm still teaching myself SPARK -- and so I've only published the file-interfacing utility portion. Have you an example of how to use it? >> 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. > > It might be a better idea to have them as TASKs and in a single program, selecting and/or creating/executing the proper task ass needed. (If you have access to the legacy-program sources, you could wrap them or their interfaces in the TASK.) Yes, I'll try in that way.