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 X-Received: by 10.66.219.104 with SMTP id pn8mr26322869pac.25.1414000902660; Wed, 22 Oct 2014 11:01:42 -0700 (PDT) X-Received: by 10.140.94.242 with SMTP id g105mr687816qge.0.1414000902325; Wed, 22 Oct 2014 11:01:42 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!h18no8843399igc.0!news-out.google.com!u5ni1qab.1!nntp.google.com!k15no114169qaq.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 22 Oct 2014 11:01:42 -0700 (PDT) In-Reply-To: <1c18d4c3-aa53-4547-85c9-55477cde7364@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=71.229.110.218; posting-account=wEPvUgoAAABrLeiz_LRhQ3jeEhyfWVMH NNTP-Posting-Host: 71.229.110.218 References: <7c1b89e6-9ab8-4faa-b60c-c5c4683f0bff@googlegroups.com> <1c18d4c3-aa53-4547-85c9-55477cde7364@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Assembling Complex Strings Containing Carriage Returns Prior to Using Ada.Text_IO.Put? From: NiGHTS Injection-Date: Wed, 22 Oct 2014 18:01:42 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3544 X-Received-Body-CRC: 602685160 Xref: news.eternal-september.org comp.lang.ada:22675 Date: 2014-10-22T11:01:42-07:00 List-Id: On Wednesday, October 22, 2014 1:44:30 PM UTC-4, Adam Beneschan wrote: > On Tuesday, October 21, 2014 10:57:39 PM UTC-7, NiGHTS wrote: >=20 > > I am converting some code from C to Ada which involves building a compl= ex string containing '\n' characters which would eventually be displayed on= the standard output console using the printf() function.=20 >=20 >=20 >=20 > > I tried to copy the same strategy of building the string in Ada like th= is: >=20 >=20 >=20 > > Complex_String : Ada.Strings.Unbounded.Unbounded_String; >=20 > >=20 >=20 > > EOL : String :=3D ASCII.CR'Img; >=20 >=20 >=20 > As others have pointed out, 'Img is a GNAT-defined attribute; it depends = on the Ada-defined attribute 'Image. 'Image is not intended to convert a C= haracter to a one-character String. If you say >=20 >=20 >=20 > C : Character :=3D 'x'; >=20 > S : String :=3D Character'Image (C); >=20 >=20 >=20 > S will have length 3 and will be "'x'". >=20 >=20 >=20 > Character is an enumeration type in Ada, although it's somewhat special. = But the rules for 'Image (and its converse, 'Value) are the same as for ot= her enumeration types: they give you (or expect) a string that looks like w= hat the enumeration value would look like in the enumeration declaration. = For example, with this enumeration type: >=20 >=20 >=20 > type Color is (RED, GREEN, BLUE); >=20 >=20 >=20 > the 'Image attribute will produce "RED", "GREEN", or "BLUE". (It's alway= s upper-case for identifiers.) And for an enumeration type that has charac= ter literals mixed in: >=20 >=20 >=20 > type Whatsit is (This, That, '?'); >=20 >=20 >=20 > 'Image will produce "THIS", "THAT", or "'?'". (What makes Character spec= ial is that if you give it a non-printable character, there are special rul= es for what 'Image returns; in your case it returned "CR".) >=20 >=20 >=20 > -- Adam This is clear to me now. I will try to avoid 'Img now that I know its GNAT-= specific, or at the very least move it to a file specifically named to be c= ompiled only in gnat. Thank you for your help.