<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
If that function does not work for you, it may be that it needs to use
the first character as a starting point for the xor:<br>
<br>
<b><font><b><font size="2">function CalcCheckSum(<b>const</b> S: <b>String</b>):
Word;<br>
<b>var</b><br>
&nbsp; i: Integer;<br>
<b>begin<br>
&nbsp; if length(s)&gt;0 then<br>
</b>&nbsp;&nbsp; result := word(s[1]);<br>
<b>&nbsp; for</b> i := 2 <b>to</b> Length(S) <b>do</b><br>
&nbsp;&nbsp;&nbsp; result := result <b>xor</b> Word(S[i]);<br>
<b>end</b></font></b></font></b><br>
<br>
Cheers,<br>
Nicholas Sherlock<br>
<br>
Jeremy Coulter wrote:
<blockquote cite="midWorldClient-F200411111653.AA53120045@vss.co.nz"
 type="cite">
  <div>Agh...dont you hate that !</div>
  <div>Someone shows you a bit of code and you go "oh yeah....DUH !!!"</div>
  <div>&nbsp;</div>
  <div>thanks Phil.</div>
  <div>&nbsp;</div>
  <div>Jeremy<br>
  </div>
  <blockquote
 style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">-----Original
Message-----<br>
From: "Phil Middlemiss" <a class="moz-txt-link-rfc2396E" href="mailto:phil@tumonz.co.nz">&lt;phil@tumonz.co.nz&gt;</a><br>
To: "NZ Borland Developers Group - Delphi List"
<a class="moz-txt-link-rfc2396E" href="mailto:delphi@ns3.123.co.nz">&lt;delphi@ns3.123.co.nz&gt;</a><br>
Date: Thu, 11 Nov 2004 16:43:50 +1300<br>
Subject: Re: [DUG] &nbsp;'exclusive or'<br>
    <br>
    <div><font face="Arial" size="2">here is a simple function I use:</font></div>
    <div>&nbsp;</div>
    <div><b><font size="2">
    <div>function CalcCheckSum(<b>const</b> S: <b>String</b>): Word;<br>
    <b>var</b><br>
&nbsp; i: Integer;<br>
    <b>begin</b><br>
&nbsp; result := 0;<br>
    <b>&nbsp; for</b> i := 1 <b>to</b> Length(S) <b>do</b><br>
&nbsp;&nbsp;&nbsp; result := result <b>xor</b> Word(S[i]);<br>
    <b>end</b><br>
    </div>
    <div><font face="Arial">probably not the fastest, but it's adequate.</font>
    </div>
    <div><font face="Arial">Cheers,</font></div>
    <div><font face="Arial">Phil.</font></div>
    </font></b></div>
    <blockquote
 style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
      <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>-----
Original Message ----- </b></div>
      <div
 style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b><b>
From:</b> <a title="vss@vss.co.nz"
 href="javascript:openWin('/WorldClient.dll?Session=EGZZBPG&View=Compose&To=vss@vss.co.nz&New=Yes','Compose',800,600,'yes');">
Jeremy Coulter</a> </b></div>
      <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b><b>To:</b>
      <a title="delphi@delphi.org.nz"
 href="javascript:openWin('/WorldClient.dll?Session=EGZZBPG&View=Compose&To=delphi@delphi.org.nz&New=Yes','Compose',800,600,'yes');">
delphi@delphi.org.nz</a> </b></div>
      <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b><b>Sent:</b>
Thursday, November 11, 2004 4:12 PM</b></div>
      <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b><b>Subject:</b>
[DUG] &#8217;exclusive or&#8217;</b></div>
      <div><b><br>
      </b></div>
      <div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">
      <b><font face="Arial" size="2"></font></b>
      <p align="left"><b><font face="Arial" size="2">Hi all.</font></b></p>
      </div>
      <p align="left"><b><font face="Arial" size="2">I am not too good
a this stuff, but I have to pass a checksum at the end of a bit of
data, and the documentation says "the checksum Is calculated by
&#8217;exclusive or&#8217; among all sent characters" </font></b></p>
      <p align="left"><b><font face="Arial" size="2">How would I do
this? </font></b></p>
      <p align="left"><b><font face="Arial" size="2">&nbsp; </font></b></p>
      <p align="left"><b><font face="Arial" size="2">Jeremy </font></b></p>
      <div>
      <hr><b>_______________________________________________<br>
Delphi mailing list<br>
      <a
 href="javascript:openWin('/WorldClient.dll?Session=EGZZBPG&View=Compose&To=Delphi@ns3.123.co.nz&New=Yes','Compose',800,600,'yes');">Delphi@ns3.123.co.nz</a><br>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a><br>
      </b></div>
    </blockquote>
  </blockquote>
  <pre wrap=""><b>
</b><hr size="4" width="90%"><b>
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</b></pre>
</blockquote>
</body>
</html>