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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,60973b026c6e423d X-Google-Attributes: gid103376,public From: Paul Tongue Subject: Re: help: character to integer Date: 1996/10/07 Message-ID: <32590D71.33B8@minster.york.ac.uk>#1/1 X-Deja-AN: 187340731 references: <52s2pl$18l@dailyplanet.wam.umd.edu> to: Eric Anthony Spear content-type: text/plain; charset=us-ascii organization: Department of Computer Science, University of York mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.02Gold (Win95; I) Date: 1996-10-07T00:00:00+00:00 List-Id: Eric Anthony Spear wrote: > > I've tried to find the answer in the RM, but I haven't had any luck. > > Is there a function, either in a package or as an attribute, that can work > like this BASIC function: > > i = ASC("X") > > That is, the function returns the ASCII value of the given character. > > Thanks in advance for any help. Eric, It has been a while since I've used Ada, but I think the predefined attribute POS is what you are looking for. Here some example code : declare I : INTEGER; C : constant CHARACTER := 'A'; S : constant STRING := "BARNES"; begin I := CHARACTER'POS(C); -- I should be 65 I := CHARACTER'POS(S(1)); -- I should now be 66 end; Hope this helps. Paul.