comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: Ascii keyword??
Date: Fri, 16 Feb 2001 13:52:46 -0500
Date: 2001-02-16T18:53:51+00:00	[thread overview]
Message-ID: <96jsvv$mr5$1@nh.pace.co.uk> (raw)
In-Reply-To: 3A8D72D4.BBB57470@blueyonder.co.uk

"Richard" <richard-blunt@blueyonder.co.uk> wrote in message
news:3A8D72D4.BBB57470@blueyonder.co.uk...
> ok am new to this ada thing, so  is there a package and/or keyword i can
> use to convert a decimal number to a acsii character and vice versa
>

It's pretty simple. There are things in Ada called "Attributes" which can be
extremely handy for a wide variety of things. In this case, there are two
attributes which are defined for all discrete types (characters being a
discrete type). They are 'Pos and 'Val and they work like function calls.
Here's basically how you would use them.

My_Int : Integer := 0 ;
My_Char : Character := ' ' ;

...

My_Char := Character'Val (33) ; -- Gives My_Char the ascii character '!'
My_Int := Character'Pos ('&') ; --  Gives My_Int the value 38.

A good example of this is in the appendix A.3.3 of the ARM. (This is where
the Latin_1 character set is defined.) If you don't have an ARM handy, look
at: http://www.adapower.org/ under "Reference" for the on-line HTML version
of the ARM. While the ARM is not the best source for teaching yourself Ada,
it is a valuable resource for looking up particulars that you may come
across in reading other texts.

Good luck with Ada!

MDC
--
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/





  parent reply	other threads:[~2001-02-16 18:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-16 18:34 Ascii keyword?? Richard
2001-02-16 18:46 ` Pascal Obry
2001-02-16 18:52 ` Marin David Condic [this message]
2001-02-16 19:29 ` Lao Xiao Hai
2001-02-16 23:22 ` David C. Hoos, Sr.
2001-02-17  0:54   ` Jeffrey Carter
2001-02-17  4:51   ` Lao Xiao Hai
replies disabled

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