Solved

Convert C++ FOR Loop to Delphi

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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