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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fb5ce1b4831d82 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-30 08:15:30 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!psinet-eu-nl!psiuk-p4!psiuk-p3!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: How to get an ASCII code ? Date: Tue, 30 Oct 2001 10:16:27 -0500 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9rmg8e$ni8$1@nh.pace.co.uk> References: <20011030-135944-285742@foorum.com> NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 1004454990 24136 136.170.200.133 (30 Oct 2001 15:16:30 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 30 Oct 2001 15:16:30 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:15416 Date: 2001-10-30T15:16:30+00:00 List-Id: This one comes up a lot. I wrote this for the FAQ & sent it to David. Anybody see anything that should be added/changed? Q: How can I get the ASCII code for a given character in Ada? A: Learn about attributes in Ada - there are a lot of them that are *very* helpful in working with the characteristics of data types and other things. In this case, you are interested in the 'Pos and 'Val attributes for discrete types. One returns the numeric position of an object of a discrete type. The other returns the discrete type value of a numeric position. As an example: X : Character := 'A' ; Y : Integer := 0 ; .... Y := Character'Pos (X) ; -- Y now contains the ASCII value of 'A' .... X := Character'Val (35) ; -- X now contains the character '#' References: ARM 3.5 (11), ARM K (175-178), ARM K (258-261) Submitted by: Marin David Condic -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/ "Matthew Heaney" wrote in message news:tttdmp64dqv206@corp.supernews.com... > > "Apokrif" wrote in message > news:20011030-135944-285742@foorum.com... > > > > How can I get the ASCII code for a given character in Ada? Is there a > function > > similar to Pascal 'ord' ? > > declare > C : constant Character := 'a'; > I : constant Natural := Character'Pos (C); > begin > > To back the other way, use Character'Val. > > > > > > > >