Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert C++ FOR Loop to Delphi

Posted on 2012-04-12
2
Medium Priority
?
539 Views
Last Modified: 2012-06-27
Hi guys,
I'm trying to convert a C++ FOR loop to Delphi, but I have no idea how to do it...

this is the C++ function:

bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
    for(;*szMask;++szMask,++pData,++bMask)
        if(*szMask=='x' && *pData!=*bMask)   return 0;
    return (*szMask) == NULL;
}

Open in new window


I just got convert the function declaration:

function bCOmpare( pData: PBYTE; bMask: PBYTE; szMask: PCHAR):boolean;
begin
//...
end;

Open in new window


How is the conversion?

Thanks
0
Comment
Question by:Mascarado
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 2000 total points
ID: 37841400
here it is:

function bCompare(pData: PBYTE; bMask: PBYTE; szMask: PChar): Boolean;
begin
  while (szMask^ <> #0) do
  begin
    if (szMask^ = 'x') and (pData^ <> bMask^) then
    begin
      Result := False;
      Exit;
    end;
    Inc(pData);
    Inc(bMask);
    Inc(szMask);
  end;

  Result := (szMask^ = #0);
end;

Open in new window

0
 

Author Closing Comment

by:Mascarado
ID: 37841843
Works sucessfully! Thank u..
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question