comp.lang.ada
 help / color / mirror / Atom feed
From: johnherro@aol.com (John Herro)
Subject: Re: Naive question
Date: 1998/08/23
Date: 1998-08-23T00:00:00+00:00	[thread overview]
Message-ID: <1998082312065701.IAA26581@ladder01.news.aol.com> (raw)
In-Reply-To: 35DF1997.3CB29CD6@tech.swh.lv

Maxim Senin <maks@tech.swh.lv> points out that
     i : Integer := Integer'Value ("m");
raises Constraint_Error.

Right.  Instead, use

     I : Integer := Character'Pos('m');

Note the single tic marks around the m.  Since 'm' is of type Character,
Character'Pos converts from Character to an integer type.  To go the other way,
Character'Val(109) converts from an integer type to Character.  The attribute
'Value converts from type *String*, and 'Image converts *to* String.  Thus
Integer'Value("123") is 123, and Integer'Image(123) is " 123".  HTH.

- John Herro
You can download a shareware Ada Tutor program at
http://members.aol.com/AdaTutor




  reply	other threads:[~1998-08-23  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-22  0:00 Naive question Maxim Senin
1998-08-23  0:00 ` John Herro [this message]
1998-08-27  0:00 ` Steve Doiel
1998-09-19  0:00 ` Tom Moran
replies disabled

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