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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,27e95161b8834d15 X-Google-Attributes: gid103376,public From: David C. Hoos, Sr. Subject: Re: Character/Integer Conversion Date: 2000/04/03 Message-ID: <8ca7k8$v2q$1@nnrp1.deja.com>#1/1 X-Deja-AN: 606046919 References: <8c3a6e$q5p$1@nnrp1.deja.com> To: ebresie@usa.net X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) X-Http-Proxy: 1.1 x28.deja.com:80 (Squid/1.1.22) for client 205.149.60.17 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Apr 03 13:51:09 2000 GMT X-MyDeja-Info: XMYDJUIDdhoossr Newsgroups: comp.lang.ada Date: 2000-04-03T00:00:00+00:00 List-Id: In article <8c3a6e$q5p$1@nnrp1.deja.com>, ebresie@usa.net wrote: > I am sure this is a simple thing, but I am doing the following... > > I need to create a string of character which will be sent to a scsi > interface. > > I need to convert from a character into a integer so that I can make a > checksum. > > I am giving a basic code version...not verbatum > > msg : string(1..length); > > msg(1) := '~'; -- how do I get the asci value for this character? > msg(2) := 33; > msg(3) : msg(1)'value + msg(2)'value; > > this should more or less add the ascii value of the first character with > the value of the second. > I do this all the time, in the following way: Msg : String (1 .. Length); type Msg_Bytes is array (Msg'Range)of Interfaces.C.Unsigned_Char; use type Interfaces.C.Unsigned_Char; Msg_Overlay : Msg_Bytes; for Msg_Overlay'Address use Msg'Address; Now, you have Msg_Overlay, an array of numeric objects that can be maniplulated both mathematically and logically (since Unsigned_Char is a modular type), and any results written to any components of that array will show up as the appropriate Character values in Msg. Sent via Deja.com http://www.deja.com/ Before you buy.