[fpc-pascal] A simple "exception handling" question
Michalis Kamburelis
michalis at camelot.homedns.org
Sat Jan 28 22:06:04 CET 2006
Bob Richards wrote:
[...]
>
> According to the docs on function "Hex2Dec" in Strutils:
>
> "If S does not contain a valid hexadecimal value, an EConvertError exception will be raised."
>
> So, what profound lack of understanding am I suffering from? Anybody?
>
There's a bug in Hex2Dec implementation -- it returns 0 instead of
raising EConvertError. Here's a patch:
Index: strutils.pp
===================================================================
--- strutils.pp (wersja 2298)
+++ strutils.pp (kopia robocza)
@@ -1156,7 +1156,7 @@
HexStr:='$'+ S
else
HexStr:=S;
- Result:=StrTointDef(HexStr,0);
+ Result:=StrToint(HexStr);
end;
function Dec2Numb(N: Longint; Len, Base: Byte): string;
More information about the fpc-pascal
mailing list