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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5ca83d39f5b3a6c0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-07 11:53:23 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!news-out.worldnet.att.net.MISMATCH!wn3feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3B9917B0.E654661@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: quick question References: <9naqvp$rlf$1@zeus.orl.lmco.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 07 Sep 2001 18:53:23 GMT NNTP-Posting-Host: 12.86.33.233 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 999888803 12.86.33.233 (Fri, 07 Sep 2001 18:53:23 GMT) NNTP-Posting-Date: Fri, 07 Sep 2001 18:53:23 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:12912 Date: 2001-09-07T18:53:23+00:00 List-Id: mop wrote: > > I have something along these lines > > Data : SomeType is ( word1 => (x.a => 1, > x.b => Normal), > --etc > word8.checksum => Compute_Checksum); > > Compute_Checksum here is a procedure that does a "straight" sum on the > bytes. Dont care about overflow. So now i need to take whatever value > compute_checksum returns and "pack" in word8.checksum. > > I'm thinking that all i need to do is create some sort of array such that: > > type SomeType_Array is array (SomeType) of BYTE; The assignment to SomeType above shows that SomeType is not a discrete type. Only discrete types can be used to index an array. Please explain what you are really trying to achieve. This example looks a lot like a student trying to program a problem he or she does not understand using a language he or she does not understand. > > Trouble is is I'm hearing I need to do some sort of Unchecked Conversion > because of words like "Normal" which is not an integer or real, etc? Is > this true, If yes how to do this. Here is procedure Compute_Checksum > > procedure Compute_Checksum is > Checksum : BYTE : = 0; > begin > for i in SomeType_Array'First .. SomeType_Array'Last -1 loop > Checksum := Checksum + SomeType_Array (i); > end loop > word8.checksum := Checksum; > end procedure Compute_Checksum; This procedure will not work as shown above. You want to assign a value to a field. That will require a function using the syntax shown at the beginning of your posting. It will also not work because you are not specifying which instance of SomeType_Array to use. Instead you are trying to perform calculations on the type itself. I suggest you review your Ada text, as well as any notes you may have taken from lecture. If you still do not understand, you should schedule some time with your professor to clear up your misunderstandings. Jim Rogers Colorado Springs, Colorado USA