From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!spool2.mu.edu!think.com!linus!linus!linus!mbunix!eachus From: eachus@aries.mitre.org (Robert I. Eachus) Newsgroups: comp.lang.ada Subject: Re: Text_Io Questions Message-ID: Date: 30 Jan 91 00:05:19 GMT References: <1991Jan26.185319.15676@cs.wright.edu> Sender: news@linus.mitre.org (News Service) Organization: The Mitre Corp., Bedford, MA. In-Reply-To: tmcclory@valhalla.cs.wright.edu's message of 26 Jan 91 18:53:19 GMT Nntp-Posting-Host: aries.mitre.org List-Id: In article <1991Jan26.185319.15676@cs.wright.edu> tmcclory@valhalla.cs.wright.edu (Tom McClory) writes: A few novice questions on using Text_Io ... -- Actually one easy, one not.... 1) How to open a text file to append to an existing text file? -- Check the Appendix F supplied with your compiler. If it supports -- opening files in append mode, it should tell you what entry to put -- in the FORM string to do it. Unfortunately, this string is -- implementation specific, so I usually use a literal to make the -- code more portable: APPEND := constant String := ""; ... Text_Io.Open(Foo, Text_IO.Out_File, Name => "Bar", Form => Append); 2) Is there some way to write to either Standard_Output or to a file? -- You can't OPEN, CLOSE, DELETE, or RESET, the standard input and -- output files because these procedures take in out parameters. -- However, the other I/O functions are quite happy to take the value -- returned by Standard_Output as a parameter. But you want to write -- a section of code which writes something either to a named file or -- to the standard output file? Sound like a procedure with a -- parameter of Text_IO.File_Type. You should probably have an -- exception handler or code to deal with cases where the file passed -- is not open: procedure Write_Message (To: in Text_IO.File_Type, Message: in String) is Was_Closed: Boolean := not IS_OPEN(To) begin if Was_Closed then begin OPEN(To, TEXT_IO.Out_File, "Junk"); exception -- what goes here depends on how careful you need to be. end; end if; Text_IO.Put_Line(To," Junk_Message: " & Message); end Write_Message; -- Robert I. Eachus Our troops will have the best possible support in the entire world. And they will not be asked to fight with one hand tied behind their back. President George Bush, January 16, 1991