comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Computing checksum for Ada newbie
Date: Tue, 28 Aug 2001 16:43:13 GMT
Date: 2001-08-28T16:43:13+00:00	[thread overview]
Message-ID: <BSPi7.23543$sa.11910310@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 9mgcbl$49b$1@zeus.orl.lmco.com

Do you mean something like:

type BYTE is mod 256;  -- ignore overflow

type TYPE_1 is
record
 XX             :  BYTE;  -- first byte
 YY             :  BYTE;  -- second byte
 Third, Fourth, Fifth, Sixth, Seventh : BYTE;
 Checksum  :  BYTE;  -- eighth byte
end record;

function Compute_Checksum(X : in TYPE_1) return BYTE is
begin
  return X.Checksum;
end Compute_Checksum;

  or perhaps

function Compute_Checksum(X : in TYPE_1) return BYTE is
begin
  return X.XX+X.YY+X.Third+X.Fourth+X.Fifth+X.Sixth+X.Seventh;
end Compute_Checksum;

  or perhaps

procedure Compute_Checksum(X : in out TYPE_1) is
begin
  X.Checksum := X.XX+X.YY+X.Third+X.Fourth+X.Fifth+X.Sixth+X.Seventh;
end Compute_Checksum;

and similarly for TYPE_2, etc.



  reply	other threads:[~2001-08-28 16:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-28 15:11 Computing checksum for Ada newbie mop
2001-08-28 16:43 ` tmoran [this message]
2001-08-29  8:46 ` John McCabe
replies disabled

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