697

Pascal2eVB

Доброго времени суток Господа!Взялся я тут за eVB и возникли проблемы! Скудный набор ф-й! Помогите мне плз перевести из паскаля в басик вот эти ф-ииword2hexhextochrstrtoint1strtolohexstrtopackffиз вот этого модуля:CODE unit hexunit;interfacefunction Str2H2Int(s:string;count:integer):longint;function Str2H2Int1(s:string):longint;Function Word2Hex(Nbr,n:longint) : String;function hexn(a:byte):string;function hex(a:byte):string;function hex1(a:byte):string;function hexw(a:longint):string;function gethex(s:string):longint;function hextochr(s:string):char;function h(s:string):char;function strtopack(s:string;n:integer):string;function strtopackff(s:string;n:integer):string;function strtolohex(s:string;n:integer):string;function strlohex(s:string;n:integer):string;function strtoint1(s:string):longint;function Str2Hex(s:string):string;implementationuses strto;function hextochr(s:string):char;beginhextochr:=chr(ord(gethex(s)));end;function strtoint1(s:string):longint;var i,re:longint;function getnum(c:char):integer;begincase c of'0': getnum:=0;'1': getnum:=1;'2': getnum:=2;'3': getnum:=3;'4': getnum:=4;'5': getnum:=5;'6': getnum:=6;'7': getnum:=7;'8': getnum:=8;'9': getnum:=9;end;end;beginre:=getnum(s[1]);for i:=2 to length(s) dore:=re*10+getnum(s[i]);strtoint1:=re;end;function strtopack(s:string;n:integer):string;var i,j:integer; s1:string; ml:longint;beginj:=0;{for i:=1 to length(s) doif (s[i]='.') or (s[i]=',') then begin j:=length(s)-i; delete(s,i,1); end;}for i:=1 to n*2-length(s) dos:='0'+s;{if po=0 then s[1]:='0' elseif po=1 then s[1]:='1' elseif po=2 then s[1]:='2' else s[1]:='3';}s1:='';repeats1:=s1+hextochr(s[length(s)-1]+s[length(s)]);delete(s,length(s)-1,2);until length(s)=0;strtopack:=s1;end;function strtopackff(s:string;n:integer):string;var i,j:integer; s1:string; ml:longint;beginj:=0;for i:=1 to n*2-length(s) dos:=s+'F';s1:='';repeats1:=s1+hextochr(s[2]+s[1]);delete(s,1,2);until length(s)=0;strtopackff:=s1;end;function strtolohex(s:string;n:integer):string;var i,j:integer; s1:string;beginj:=0;for i:=1 to length(s) doif (s[i]='.') or (s[i]=',') then begin j:=length(s)-i; delete(s,i,1); end;for i:=1 to n*2-length(s) dos:='0'+s;s1:='';repeats1:=s1+hextochr(s[length(s)-1]+s[length(s)]);delete(s,length(s)-1,2);until length(s)=0;strtolohex:=s1;end;function strlohex(s:string;n:integer):string;var i,j:integer; s1:string;beginj:=0;for i:=1 to length(s) doif (s[i]='.') or (s[i]=',') then begin j:=length(s)-i; delete(s,i,1); end;for i:=1 to n*2-length(s) dos:='0'+s;s1:='';repeat{write(s[length(s)-1],s[length(s)],' ');}s1:=s1+s[length(s)-1]+s[length(s)];delete(s,length(s)-1,2);until length(s)=0;strlohex:=s1;end;function h(s:string):char;beginh:=chr(ord(gethex(s)));end;Function Word2Hex(Nbr,n:longint) : String;Var Count : Byte; {Digit counter/index} Digit : Byte; {Digit isolated from (Nbr) passed} Hex : String; {Conversion buffer/return string}Beginhex:='';digit:=0; For Count := n Downto 1 Do Begin Digit := Nbr And $0F; {Isolate least significant digit} Inc(Digit,48); {Add ASCII digit offset} If Digit > 57 Then Inc(Digit,7); {Add offset for letters A-F} Hex[Count] := Chr(Digit); {Store result in return string} Nbr := Nbr SHR 4; {Move next digit to 1's position} End;case n of4: Hex[0] := #4;5: Hex[0] := #5;6: Hex[0] := #6;7: Hex[0] := #7;8: Hex[0] := #8;9: Hex[0] := #9;10: Hex[0] := #10;11: Hex[0] := #11;12: Hex[0] := #12;13: Hex[0] := #13;14: Hex[0] := #14;15: Hex[0] := #15;end; {Force return string length to 4 chars} Word2Hex := Hex; {Return ASCII HEX result string}End;function hexn(a:byte):string;const h:array[0..15] of char='0123456789ABCDEF';beginhexn:=h[a and 15];end;function hex(a:byte):string;const h:array[0..15] of char='0123456789ABCDEF';beginhex:=h[a shr 4]+h[a and 15];end;function hex1(a:byte):string;const h:array[0..15] of char='0123456789ABCDEF';beginhex1:=h[a shr 4]+h[a and 15];end;function hexw(a:longint):string;beginhexw:=hex(hi(a))+hex(lo(a));end;function gethex(s:string):longint;var i,res:longint;beginres:=0;for i:=1 to length(s) doif s[i]>'9' then res:=res shl 4+ord(upcase(s[i]))-55else res:=res shl 4+ord(s[i])-48;gethex:=res;end;function Str2H2Int(s:string;count:integer):longint;var i:integer; tmp:string;begintmp:='';for i:=count downto 1 dotmp:=tmp+hex(ord(s[i]));Str2H2Int:=gethex(tmp);end;function Str2H2Int1(s:string):longint;var i:integer; tmp:string;begintmp:='';for i:=length(s) downto 1 dotmp:=tmp+hex(ord(s[i]));Str2H2Int1:=gethex(tmp);end;function Str2Hex(s:string):string;var i:integer; tmp:string;begintmp:='';for i:=length(s) downto 1 dotmp:=tmp+hex(ord(s[i]));Str2Hex:=tmp;end;end.
0