Solved

Convert C++ FOR Loop to Delphi

Posted on 2012-04-12
2
528 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 500 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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dev Express grid collapse 2 47
Press three keys together and trigger a function 3 67
Unique identifier on a terminal server (rdp) 4 74
How to build JSON File in Delphi 6 3 70
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

749 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