| function Hex2Int64 (const S: string): Int64;
var
     S2: string;
     L: Int64;
     Error: Integer;
begin
     S2 := UpperCase (StripChFromStr (S, WhiteSpaceSet));
     if (Length (S2) > 1) and (S2 [1] <> '$') then
          S2 := '$' + S2;
     { Some Delphi/Kylix versions have problems with the following so we
      handle them as special cases. }
     if S2 = '$FFFFFFFFFFFFFFFF' then
     begin
          Result := -1;
          Exit;
     end;
     if S2 = '$8000000000000000' then
     begin
          Result := Low (Int64);
          Exit;
     end;
     try
          Val (S2, L, Error);
          if Error <> 0 then
               Result := 0 // Return 0 for non-numeric
          else
               Result := L; // Return Value
     except
          Result := 0; // Return 0 for non-numeric
     end;
End; |