Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
STR2HEX e HEX2STR...
Message
From
06/09/2004 00:26:32
Peter Wagner
Point Informática Ltda.
Limeira, Brazil
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00939373
Message ID:
00939648
Views:
20
Obrigado,
nem lembrava do HexEdit no VFP.
Valeu.

[ ], s
Peter

>Transforme a String em Numerico com ASC e depois use o Trasform com @0 ( zero ).
>
>Veja as funções tiradas de um exemplo que vem com o VFP. Veja em C:\Program Files\Microsoft Visual FoxPro 8\Tools\HexEdit
>
>
>FUNCTION Dec2Hex
>PARAMETER nDecimal, nDigits
>**  Converts from base 10 to base 16.  Returns Hex notation in a string whose length
>**  is always at least 2.  The nDigits parameter can be specified to pad the
>**  string with zeroes.
>
>IF PARAMETERS() = 2
>	RETURN RIGHT(TRANSFORM(nDecimal, "@0"), IIF(nDigits <= 8, nDigits, 8))
>ENDIF
>LOCAL nExponent
>*  If no second parameter, must determine correct number of digits.
>nExponent = 2	&& Always return at least two characters.
>DO WHILE nExponent < 9
>	IF nDecimal <= (16^nExponent)
>		RETURN RIGHT(TRANSFORM(nDecimal, "@0"), nExponent)
>	ENDIF
>	nExponent = nExponent + 1
>ENDDO
>
>
>
>*********************************************
>*	Hex2Dec:	Translates Hex (in a string) to
>* 				a decimal
>*	Returns:	Numeric
>*********************************************
>LParameters cDigits
>RETURN EVALUATE("0x" + ALLTRIM(cDigits))
>
Previous
Reply
Map
View

Click here to load this message in the networking platform