Code Snippets Database
Control Box
Requested snippets
This page displays 4 requested snippets.
You can choose a category, perform a search or generate a Pascal unit containing the snippets by using the Control Box.
- TryHexToBytes
-
Writes the bytes represented by a hexadecimal string into a byte array. Returns True on success or False if HexStr is either empty or contains invalid hex characters.
function TryHexToBytes(HexStr: string; out Bytes: TBytes): Boolean; begin SetLength(Bytes, HexByteSize(HexStr)); Result := TryHexToBuf(HexStr, Bytes[0]); end;
Kind of Snippet: RoutineRequired units: None.Supported Compilers:D2 D3 D4 D5 D6 D7 D2005
(Win32)D2006
(Win32)D2007 D2009
(Win32)D2010
(Win32)Free
Pascal










This snippet cannot be included in generated units. - HexToBuf
-
Writes the bytes represented by a hexadecimal string into a buffer, which must be large enough to receive the data.
procedure HexToBuf(HexStr: string; var Buf); {$IFDEF FPC} const {$ELSE} resourcestring {$ENDIF} sHexConvertError = '''%s'' is not a valid hexadecimal string'; begin if not TryHexToBuf(HexStr, Buf) then raise SysUtils.EConvertError.CreateFmt(sHexConvertError, [HexStr]); end;Kind of Snippet: RoutineRequired units: None.Required snippets: TryHexToBuf.Supported Compilers:D2 D3 D4 D5 D6 D7 D2005
(Win32)D2006
(Win32)D2007 D2009
(Win32)D2010
(Win32)Free
Pascal











- HexToInt
-
Converts a hexadecimal string to an integer. Raises an exception if the string is not valid hexadecimal.
function HexToInt(const HexStr: string): Integer; {$IFDEF FPC} const {$ELSE} resourcestring {$ENDIF} sHexConvertError = '''%s'' is not a valid hexadecimal value'; begin if not TryHexToInt(HexStr, Result) then raise SysUtils.EConvertError.CreateFmt(sHexConvertError, [HexStr]); end;Kind of Snippet: RoutineRequired units: None.Required snippets: TryHexToInt.Supported Compilers:D2 D3 D4 D5 D6 D7 D2005
(Win32)D2006
(Win32)D2007 D2009
(Win32)D2010
(Win32)Free
Pascal











- HexToInt64
-
Converts a hexadecimal string to a 64 bit integer. Raises an exception if the string is not valid hexadecimal.
function HexToInt64(const HexStr: string): Int64; {$IFDEF FPC} const {$ELSE} resourcestring {$ENDIF} sHexConvertError = '''%s'' is not a valid hexadecimal value'; begin if not TryHexToInt64(HexStr, Result) then raise SysUtils.EConvertError.CreateFmt(sHexConvertError, [HexStr]); end;Kind of Snippet: RoutineRequired units: None.Required snippets: TryHexToInt64.Supported Compilers:D2 D3 D4 D5 D6 D7 D2005
(Win32)D2006
(Win32)D2007 D2009
(Win32)D2010
(Win32)Free
Pascal











