Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:20:57+00:00 2026-05-25T14:20:57+00:00

I am trying to convert a C code to Delphi/pascal, but somehow I cannot

  • 0

I am trying to convert a C code to Delphi/pascal, but somehow I cannot get it to work, my approach was like this :

function CheckLRC(s : PChar) : Char;
var
  sum : char;
begin
  sum := #0;
  while (^s <> #0) do
  begin
    sum := (sum XOR ^s);
    inc (s)
  end;
  result := sum;
end;

Original C code was :

   Set LRC = 0
   For each byte b in the buffer
   do
     Set LRC = (LRC + b) AND 0xFF
   end do
   Set LRC = (((LRC XOR 0xFF) + 1) AND 0xFF)

Hope anyone out there is able to help me, and can confirm this is the correct way to do an LRC checksum ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:20:57+00:00Added an answer on May 25, 2026 at 2:20 pm

    I guess the exact equivalence of this function may be:

    function CheckLRC(const s: AnsiString): byte;
    var i: integer;
    begin
      result := 0;
      for i := 1 to length(s) do
        inc(result,ord(s[i]));
      result := (result xor $FF)+1; // or result := (not result)+1;
    end;
    

    All “and $FF” in original code is unneeded here, since we are using a byte as result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert a function from Javascript to CoffeeScript. This is the code:
I'm trying to convert some code that worked great in VB, but I can't
I'm trying to convert a character code to a character with chr(), but VBScript
I am trying to convert this test code to C# and having a problem
Im trying to convert some Delphi code to c# and I've come across a
I am trying to convert this code in my DI mapping from Unity to
I'm trying to convert some C# code to VB but I’m getting an error.
I am trying to convert this C code I have into a python script
I am trying to convert the code snippet given in this http://www.movable-type.co.uk/scripts/latlong.html into java.
I trying to convert this C# code VB.Net. its giving syntax error. C# @{

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.