?? myutils.pas
字號:
unit myUtils;
interface
function Str2Word(str : String): Integer;
function Str2Char(str: String) : Integer;
implementation
function GetCharHexValue(ch: Char) : Integer;
begin
if ch in ['0'..'9'] then
Result := Integer(Ord(ch) - Ord('0'))
else
begin
ch := UpCase(ch);
if ch in ['A'..'F'] then
Result := Integer(Ord(ch) - Ord('A') + 10)
else
Result := -1;
end;
end;
function Str2Char(str: String) : Integer;
var
i1, i2:integer;
begin
Result := -1;
if( Length(str) = 2) then
begin
i1 := GetCharHexValue(str[1]);
i2 := GetCharHexValue(str[2]);
if( i1 <> -1) and (i2 <> -1) then
Result := i1*16 + i2;
end;
end;
function Str2Word(str : String): Integer;
var
i1, i2 ,i3, i4: Integer;
begin
Result := -1;
if( Length(str) = 4) then
begin
i1 := GetCharHexValue(str[1]);
i2 := GetCharHexValue(str[2]);
i3 := GetCharHexValue(str[3]);
i4 := GetCharHexValue(str[4]);
if( i1 <> -1) and (i2 <> -1) and (i3 <> -1) and (i4 <> -1) then
Result := i1*16*16*16 + i2*16*16 + i3*16 + i4;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -