Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decimal to hexadecimal
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00402852
Message ID:
00403158
Vues:
18
Hi Alex,

Talking about jumping the gun...

What I wanted was to convert a decimal value between 0 and 255 - which is what asc() returns - into the "binary string".

My input is a character, read from a serial port, let's call it inChar, so to get what I want I needed something like:
substr("0000000100100011010001010110011110001001101010111100110111101111", ;
       4*eval('0x'+subs(tran(asc(inChar),'@0'),9,1)) + 1, 4) + ;
substr("0000000100100011010001010110011110001001101010111100110111101111", ;
       4*eval('0x'+subs(tran(asc(inChar),'@0'),10,1)) + 1, 4)
It looks a little too convoluted, and is almost as slow as the API call, and not much faster than the existing UDF which has about 40 lines of code.
I'm not sure if, at least, is clearer from a code maintenance pov.

What do you think?
Doru
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform