The following functions work exactly like "SysUtils.IntToStr/Hex", but with
extended functionality. You can specify how long the resulting string has
to be at least and which character is used as the fill character. If you set
"minLen" to be negative the fill characters are appended to the end of the
string, else they're inserted at the beginning. Besides, IntToHexEx always
adds a "$" to the string.
|
function IntToStrEx (value : integer;
minLen : integer = 1;
fillChar : char = '0') : string; overload;
function IntToStrEx (value : cardinal;
minLen : integer = 1;
fillChar : char = '0') : string; overload;
function IntToStrEx (value : int64;
minLen : integer = 1;
fillChar : char = '0') : string; overload;
function IntToHexEx (value : integer;
minLen : integer = 1;
fillChar : char = '0') : string; overload;
function IntToHexEx (value : cardinal;
minLen : integer = 1;
fillChar : char = '0') : string; overload;
function IntToHexEx (value : int64;
minLen : integer = 1;
fillChar : char = '0') : string; overload;
IntToHexEx($123 ) -> '$123'
IntToStrEx( 123, 5) -> '00123'
IntToHexEx($123, 5) -> '$00123'
|
|
The function "StrToIntEx" converts a decimal or hexadecimal string to an
integer. No exceptions are raised, an invalid string results in an invalid
result. This function is *very* fast.
|
function StrToIntEx (hex : boolean;
str : pchar;
len : integer) : integer;
StrToIntEx(false, '12345678', 8) -> 12345678
StrToIntEx(true, '12345678', 8) -> $12345678
StrToIntEx(true, '1234test', 8) -> $12340E00 (invalid result)
|
|
The function "BooleanToChar" converts a boolean value into a '+' or '-'
string:
|
function BooleanToChar (bool: boolean) : string;
BooleanToChar(false) -> '-'
BooleanToChar(true ) -> '+'
|
|
The following function converts a size ordinal into a string:
|
function SizeToStr (size: int64) : string;
500 -> '500 Bytes'
1024 -> '1 KB'
1024*1024 -> '1 MB'
|
|
The function "MsToStr" converts a millisecond value to a time string:
|
function MsToStr (time: cardinal) : string;
15 -> '15 ms'
1000 -> '1 s'
60*1000 -> '1 min'
60*60*1000 -> '1 h'
61*60*1000 -> '1:01 h'
|
|
The following function converts a Windows error code into a string. Basically
it works like "SysUtils.SysErrorMessage", but it can also convert network
error codes, what "SysErrorMessage" doesn't do. However, in order to do that
it needs the dll "NetMsg.dll". If it's not found, the network errors can't be
converted. The dll is included in every winNT and win2000 installation.
Furthermore you can copy it into your application's folder, the NT/2000 dll
works also in win9x. I'm not sure about whether you're allowed to do so,
though.
|
function ErrorCodeToStr (error: cardinal) : string;
ERROR_ACCESS_DENIED -> 'Access denied'
NERR_InvalidComputer -> 'This computer name is invalid'
|
|