comp.lang.ada
 help / color / mirror / Atom feed
From: Steve Kerr <stephen.kerr@gecm.com>
Subject: Re: help Please
Date: 1999/01/26
Date: 1999-01-26T00:00:00+00:00	[thread overview]
Message-ID: <36ADB3F7.7A239560@gecm.com> (raw)
In-Reply-To: m3u2xgwa9x.fsf@mheaney.ni.net

Matthew Heaney wrote:

[....snip snip.....]

> If you want to add two characters together, then just define an operator
> to do that:
>
>  function "+" (L, R : Character) return Character is ...;
>
> You can't "typecast" a character to integer, like this
>
>      ... Integer (C) ...
>
> but of course you can convert a character into its underlying integer
> representation either by using Unchecked_Conversion or Character'Pos.
>

  More simply, you can use the value attribute. For example

    integer'value("4")

will give you the integer value 4, not the code for ASCII "4".

This attribute can be used with any string representing a discrete type, so
I guess boolean'value("TRUE") works too (although I have only ever tried it
with numeric values). Leading and trailing spaces in the string are ignored,
so there's no need to trim it. As a matter of interest, this 'value is the
opposite of 'image.

BTW Jarrod, if the computer does not know how to add, what does it do with
the '+' operator in your example ;-)







  parent reply	other threads:[~1999-01-26  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <36ab9be5.2873369@news.ptd.net>
1999-01-24  0:00 ` help Please Matthew Heaney
1999-01-26  0:00   ` Simon Wright
1999-01-26  0:00   ` Steve Kerr [this message]
1999-01-26  0:00     ` David C. Hoos, Sr.
1999-01-27  0:00       ` Steve Kerr
1999-01-27  0:00         ` Tucker Taft
2000-05-22  0:00 help please saju sathyan
2000-05-22  0:00 ` Gautier
2000-05-23  0:00   ` saju sathyan
  -- strict thread matches above, loose matches on Subject: below --
2001-12-16 15:27 Pierrick
2001-12-16 18:27 ` Patrick Hohmeyer
2001-12-16 19:46 ` Steve Doiel
replies disabled

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