Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Decimal to hexadecimal
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00402852
Message ID:
00403158
Views:
17
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform