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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How to write "Hello" to a text file without a line terminator Date: Fri, 12 Aug 2016 08:46:18 +0100 Organization: A noiseless patient Spider Message-ID: References: <2cc97e17-313e-44b8-b335-8d5e815e925a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="809230ccffd7ccb97232ccf9bda16930"; logging-data="30916"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yc/frvdYt0oP2oUeNIsC8XHyQXLOVIos=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:gbCuLCPjYlvISXUVbgVA/+6CqkU= sha1:+DmiL4D2dSm/IXOJDcsPrMU3Q6s= Xref: news.eternal-september.org comp.lang.ada:31414 Date: 2016-08-12T08:46:18+01:00 List-Id: "Dmitry A. Kazakov" writes: > On 12/08/2016 06:05, Jerry wrote: >> How does one write "Hello" to a text file without a line terminator? >> >> Put("Hello"); >> >> adds a line terminator after "Hello". > > No, it does not, if you are talking about the standard library Put. > > It is Put_Line that does. Dmitry, Jerry has obviously seen this behaviour under _some_ circumstances, so perhaps we should think about what those circumstances might have been! If the 'Put("Hello");' is the last output before the output file is closed, probably by ending the program, then ARM A.10.2(3) applies: For the procedure Close: If the file has the current mode Out_File or Append_File, *has the effect of calling New_Page*, unless the current page is already terminated; then outputs a file terminator. and ARM A.10.5(16) for New_Page: Operates on a file of mode Out_File or Append_File. *Outputs a line* *terminator if the current line is not terminated*, or if the current page is empty (that is, if the current column and line numbers are both equal to one). Then outputs a page terminator, which terminates the current page. Adds one to the current page number and sets the current column and line numbers to one. Use Ada.Stream_IO, as already suggested, or GNAT.IO - of course the latter isn't standardised nd its behaviour might change.