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 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5272f2ce638e3a38 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-07 09:46:27 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!gatech!swrinde!cs.utexas.edu!news.sprintlink.net!uunet!telesoft!kst From: kst@alsys.com (Keith Thompson) Subject: Re: Opening a File for Appending Message-ID: Originator: kst@pulsar Sender: news@alsys.com (USENET News Admin @flash) Organization: Alsys, San Diego, CA, USA References: <847@trident.datasys.swri.edu> <3ejufu$g56@Starbase.NeoSoft.COM> Date: Sat, 7 Jan 1995 01:28:44 GMT Date: 1995-01-07T01:28:44+00:00 List-Id: In <3ejufu$g56@Starbase.NeoSoft.COM> dweller@Starbase.NeoSoft.COM (David Weller) writes: > Um, in Ada95, one of the file modes is Append_File (for any of Text, > Sequential, Wide, and Stream_IO files). > > Appending a file in Ada83 is OS dependent (unless the POSIX binding > supports this -- I'm not sure). Yes it does, via the Form parameter of Text_IO.Open. Here's a test/demo program; you can compile and execute it to find out whether your implementation supports POSIX-style appending to a text file. Note that it isn't necessary to explicitly "with" any POSIX packages; POSIX specifies this behavior for the LRM-defined Text_IO package. with Text_IO; procedure Append_Test is File: Text_IO.File_Type; File_Name: constant String := "append.txt"; Line1: constant String := "First line"; Line2: constant String := "Second line"; Ok: Boolean := True; begin Text_IO.Create( File => File, Mode => Text_IO.Out_File, Name => File_Name ); Text_IO.Put_Line(File, Line1); Text_IO.Close(File); Text_IO.Open( File => File, Mode => Text_IO.Out_File, Name => File_Name, Form => "Append => True" ); Text_IO.Put_Line(File, Line2); Text_IO.Close(File); declare S: String(1 .. 100); Last: Natural; begin Text_IO.Open( File => File, Mode => Text_IO.In_File, Name => File_Name ); Text_IO.Get_Line(File, S, Last); if S(S'First .. Last) /= Line1 or Text_IO.End_Of_File(File) then Ok := False; else Text_IO.Get_Line(File, S, Last); if S(S'First .. Last) /= Line2 then Ok := False; end if; end if; exception when others => Ok := False; end; begin Text_IO.Delete( File ); exception when others => Ok := False; end; if Ok then Text_IO.Put_Line("This implementation supports POSIX-style"); Text_IO.Put_Line("appending to a text file via the Form parameter."); else Text_IO.Put_Line("This implementation does not support POSIX-style"); Text_IO.Put_Line("appending to a text file via the Form parameter,"); Text_IO.Put_Line("or some other problem occurred."); end if; end Append_Test; -- Keith Thompson (The_Other_Keith) kst@thomsoft.com (kst@alsys.com still works) TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718 When you're a nail, every problem looks like a hammer.