Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with Pointers

Status
Not open for further replies.

minckle

Programmer
Mar 17, 2004
142
GB
Im Using Delphi 5 and found a bit of code on the net

Code:
function HexToInt(W: PWord): Byte;
var
B, C: Byte;
begin
B := Lo(W^) - Ord('0');
if B > 9 then Dec(B, 7);
C := Hi(W^) - Ord('0');
if C > 9 then Dec(C, 7);
Result := B shl 4 + C;
end;

Error:
Undeclared Indentifier: 'PWord' and
Pointer Type Required for line - B := Lo(W^) - Ord('0');


Unfortunately i can't get the code to compile,my errors are above.

Can anyone help??
Thanks
 
you need a declare a "pointer to word type"

add this in the interface section :

type Pword = ^Word;

--------------------------------------
What You See Is What You Get
 
Or you could let Delphi do the hardwork and use a simpler method:
Code:
function HexToInt(AHexStr: String): Integer;
begin
  Result := StrToInt('$' + AHexStr);
end;

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top