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

  • SEARCH
  • Home
  • 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 610081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:38:12+00:00 2026-05-13T17:38:12+00:00

I have ported our project from Delphi 7 to Delphi 2010. After adding some

  • 0

I have ported our project from Delphi 7 to Delphi 2010. After adding some type casts now my project is running well and all the features work correctly except main functionality of the program which is bound to COM ports and the MSCOMM ActiveX component.

It can read and write from a COM port but it seems something is wrong with that because the device that connected to he port returns error code although it works correctly with same code in Delphi7. In the code you can see below after sending some bytes to the device a byte is sent as checksum. On the other side the device gets the bytes and calculates check sum with same formula if received check sum was equal with calculated check sum device returns “O” as OK else it returns “E” as Error. OutCom is defined as Olevariant.

OutCom := chr(ord(Fbyte));
Mscomm1.Output := OutCom;

OutCom := chr(ord(Sbyte));
Mscomm1.Output := OutCom;

OutCom := chr(ord(DigitOne));
Mscomm1.Output := OutCom;
OutCom := chr(ord(DigitTwo));
Mscomm1.Output := OutCom;
OutCom := chr(ord(DigitThree));
Mscomm1.Output := OutCom;
SumOfBits := (System_No - 1) + Fbyte + Sbyte + DigitOne + DigitTwo + DigitThree;

CheckSum := ( (SumOfBits mod 256) xor 255 ) + 1;

OutCom := chr(ord(CheckSum));
Mscomm1.Output := OutCom;

OutCom := 'E';
Mscomm1.Output := OutCom;
OutCom := 'N';
Mscomm1.Output := OutCom;

Same code in Delphi 2010 returns different result. I guess that the chr() function returns a different result as Delphi7. If this is true then how can I get the Ascii char of a byte or is there a way to pass a byte to Mscomm without converting to char?

  • 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-13T17:38:13+00:00Added an answer on May 13, 2026 at 5:38 pm

    Chr now returns a Unicode WideChar (pre-Delphi 2009, it returned a single-byte AnsiChar).

    The easiest solution is to typecast byte values to ansischar :

    var_ansichar := AnsisChar(var_byte);
    

    instead of using Chr(). But note what Mghie says. Make sure the typing of your components, declared variables etc is right (AnsiChar, AnsiString etc).

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

Sidebar

Related Questions

I have just ported several of our home-made Outlook COM-addins from Delphi 2007 to
Our team is currently using some ported code from an old architecture to a
I ported one project from Visual C++ 6.0 to VS 2010 and found that
I have tried to find all Validators in our project in Visual Studio 2010.
I have ported a search from Coldfusion into a MySQL stored procedure. The actual
I have a project being ported to work on Linux under Mono. The project
In one of our components ported from Java to C#, we used FileInfo as
We have a c++ application which I recently ported from Linux/gcc to build on
I have a GWT app that I ported to GWT 2.4. Now I geta
We just ported our WinForms application to WPF. However, performance decreased dramatically. We have

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.