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,abc6a29c7c19fbc8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-29 01:48:01 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!212.74.64.35!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!pipehawk.demon.co.uk!not-for-mail From: john.mccabe@emrad.com.nospam (John McCabe) Newsgroups: comp.lang.ada Subject: Re: Computing checksum for Ada newbie Date: Wed, 29 Aug 2001 08:46:14 GMT Organization: Emrad Ltd Message-ID: <3b8cab8a.3635477@news.demon.co.uk> References: <9mgcbl$49b$1@zeus.orl.lmco.com> NNTP-Posting-Host: pipehawk.demon.co.uk X-NNTP-Posting-Host: pipehawk.demon.co.uk:158.152.226.81 X-Trace: news.demon.co.uk 999074820 nnrp-13:17919 NO-IDENT pipehawk.demon.co.uk:158.152.226.81 X-Complaints-To: abuse@demon.net X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:12548 Date: 2001-08-29T08:46:14+00:00 List-Id: On Tue, 28 Aug 2001 11:11:47 -0400, "mop" wrote: >I've got two types - we'll call them TYPE_1, TYPE_2. > >The checksum (last byte) for TYPE_1 is the byte eight. >The checksum (last byte) for TYPE_2 varies (depends on user parameters) but >the threshold is byte 517. >The checksum is a simple sum of the the bytes (dont care about overflow) >An example of TYPE_1 is provided. "BYTE" is defined in my package. > >type TYPE_1 is >record > XX : BYTE; -- first byte > YY : BYTE; -- second byte >-- etc > Checksum : BYTE; -- eighth byte >end record; > >I want a function - we'll call it Compute_Checksum that'll sum the bytes > >function Compute_Checksum return BYTE is -- dont think this is right. need >to pass in which type > INTEGER : Checksum :=0; >begin >-- more help here >end Compute_Checksum; > > It's not 100% clear what you require here, but I would probably use unchecked conversion of the record into a packed array of bytes then calculate the checksum in a loop. Some people might consider this cheating, but ... :-) Best Regards John McCabe