comp.lang.ada
 help / color / mirror / Atom feed
From: Paul Tongue <pault@minster.york.ac.uk>
To: Eric Anthony Spear <spear@wam.umd.edu>
Subject: Re: help: character to integer
Date: 1996/10/07
Date: 1996-10-07T00:00:00+00:00	[thread overview]
Message-ID: <32590D71.33B8@minster.york.ac.uk> (raw)
In-Reply-To: 52s2pl$18l@dailyplanet.wam.umd.edu


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.




      parent reply	other threads:[~1996-10-07  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-01  0:00 help: character to integer Eric Anthony Spear
1996-10-02  0:00 ` Dave Marshall
1996-10-02  0:00 ` Richard A. O'Keefe
1996-10-02  0:00   ` George Haddad
1996-10-02  0:00     ` David C. Hoos, Sr.
1996-10-02  0:00     ` Robert A Duff
1996-10-05  0:00     ` Robert Dewar
1996-10-07  0:00       ` the term "pound sign" (was: help: character to integer) Adam Beneschan
1996-10-09  0:00         ` Michael Feldman
1996-10-09  0:00           ` Robert Dewar
1996-10-09  0:00             ` Michael Feldman
1996-10-10  0:00             ` Richard Kenner
1996-10-10  0:00               ` Adam Beneschan
1996-10-11  0:00           ` Robert I. Eachus
1996-10-11  0:00             ` Robert Dewar
1996-10-07  0:00 ` Paul Tongue [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox