Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I read a hex value from an ascii file
Message
De
23/11/1996 13:16:41
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00013211
Message ID:
00013250
Vues:
34
>> The file contains inventory balances, and those are written in a hexadecimal value in the same record. Is there a good way to read that value and convert it into numbers that VFP can understand?
>
>Beats me why they would store an inventory value in hex format. Regardless, given a string S containing a hexadecimal value such as "0A3F".
>
>Function HexToNumeric
>parameter s
>s=Upper(s)
>Local x,p,tot,d
>x=len(s)
>p=1
>tot=0
>do while x > 0
> d=asc(substr(s,x))
> d= iif ( d > 64, d-55, d-48)
> tot = tot + d * p
> p = p * 16 && or you can bitshift left 4 if you want
> x = x - 1
>enddo
>return tot
>
>This doesn't take advantage of some optimization techniques because it was originally written for Foxbase in 1987 and I've been to lazy to update it.


THANKS BUNCHES! Maybe I can return the favor one day!

John Dennis
DAKOTA DATA TECHNOLOGIES
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform