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=-0.5 required=3.0 tests=BAYES_05,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a37:8b01:: with SMTP id n1mr5498058qkd.370.1596219597612; Fri, 31 Jul 2020 11:19:57 -0700 (PDT) X-Received: by 2002:a37:8c02:: with SMTP id o2mr3395657qkd.461.1596219594397; Fri, 31 Jul 2020 11:19:54 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 31 Jul 2020 11:19:54 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <868e4e17-8624-421d-86bb-64d682a691a9o@googlegroups.com> Subject: Re: Ada.Text_IO.File_Type object with user defined Get and Put subprograms. From: Shark8 Injection-Date: Fri, 31 Jul 2020 18:19:57 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:59615 List-Id: 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. > > 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.)