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!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Text_IO, was: Re: Something I don't understand Date: Thu, 20 Feb 2014 09:06:20 +0200 Organization: Tidorum Ltd Message-ID: References: <4a3e55f6-9f54-4084-9f37-96efd4b0d349@googlegroups.com> <0b358700-871b-4603-addd-65e07c7d59e5@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net c+fq6m3wrVoS+0ZWKTIa7AAWz3Z73gBRbRJAd0Y20EeYeAKItO Cancel-Lock: sha1:pXTNYhxzXSJWCsLCcCYCmOooxyc= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:18694 Date: 2014-02-20T09:06:20+02:00 List-Id: On 14-02-20 03:09 , Simon Clubley wrote: > On 2014-02-19, Jeffrey Carter wrote: >> On 02/19/2014 02:46 PM, Robert A Duff wrote: >>> >>> Put("There were \1 warnings and \2 errors.\n", >>> Image(Warning_Count), Image(Error_Count)); >> >> And then you end up with >> >> There were 1 warnings and 1 errors. >> >> I suppose you could have >> >> Put ("There were \1 \2 and \3 \4.\n", >> Image (Warning_Count), >> (if Warning_Count = 1 then "warning" else "warnings"), >> Image (Error_Count), >> (if Error_Count = 1 then "error" else "errors") ); >> >> but then the Template is essentially unreadable. >> > > Are you familiar with the VMS $FAO directive (which is the way VMS does > template formatting) ? > > Background material on $FAO is at: > > http://h71000.www7.hp.com/doc/82final/4527/4527pro_047.html > > The table of formatting directives are at the bottom of that page. > > Of interest is the directive "!%S" which inserts either "S" or "s" if > the most recent numeric value was not one, the directive "!n%C" which > inserts a specific string if the previous numeric field value matches > the "n" condition and the "!%E" directive which inserts a string if the > previous numeric field value did _not_ match a previous "!n%C" test. > > Something like that would handle this problem rather cleanly. Cleanly? I would call those directives "line-noise formatting". Trying to embed logical decisions into the template string is yucky. Concatenating conditional string expressions in Ada is a lot cleaner IMO. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .