Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comparing char to hex
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
SAMBA Server
Database:
Visual FoxPro
Divers
Thread ID:
01054856
Message ID:
01054882
Vues:
22
Thank you! What an absolute mess just to do a simple comparison!!!

>
lcStr = "Joe"
>lcHex = "0x"
>FOR i=1 TO LEN(lcStr)
>	lcHex = lcHex + RIGHT(TRANSFORM(ASC(SUBSTR(lcStr,i,1)), "@0"),2)
>ENDFOR
>
>? lcHex, lcHex = "0x4A6F65"
>
>
>>That will only work with 1,2,4 or 8 bytes though correct?
>>
>>>
CTOBIN(retval + CHR(0),"4S") = 0x4A6F6500
>>>
>>>>Operator/Operand mismatch on my code.
>>>>
>>>>If retval="Joe" it should equal 0x4A6F65 not "0x004A6F65".
>>>>
>>>>? TRANSFORM("Joe", "@0") displays "Joe" not 0x4A6F65.
>>>>
>>>>
>>>>>Your code should work. What seems to be a problem? You can try
IF TRANSFORM(retval, "@0") = "4A6F65"
>>>>>* or
>>>>>retval = "0x004A6F65"
>>>>>
>>>>>
>>>>>
>>>>>>Is there any way I can do a comparison from char to hex?
>>>>>>
>>>>>>
>>>>>>retval=FREAD(f,3)
>>>>>>if retval=0x4A6F65
>>>>>>  do something
>>>>>>endif
>>>>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform