Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binary to Hex Conversion
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00036266
Message ID:
00036310
Views:
49
>>
>>Thanks George, I'll try it out. What I'm needing to do is transmit data to a remote server program. The remote program can accept optional fields i the middle of the string. The first field to send is a hex representation of the binary on/off (yes/no) of which fields are sent. For example, if field 5 is sent, then the 5th position in the binary number is set, etc.
>>
>>Craig
>
>I feel like I sent you "half-a-loaf". Here's the rest:
>
>FUNCTION BStr2Hex
>
>LPARAMETER pc_bstr
>
>LOCAL lnvalue, lcresult, lnmask, lchex,;
> lni, lnnybble
>lcresult = ""
>lnvalue = BStr2Int(pc_bstr)
>lnmask = 15
>lchex = '0123456789ABCDEF'
>FOR lni = 1 TO 8
> lnnybble = BITRSHIFT(lnvalue, (lni - 1) * 4)
> lnnybble = BITAND(lnnybble, lnmask)
> lcresult = SUBSTR(lchex, lnnybble + 1, 1) + lcresult
>NEXT
>RETURN lcresult
>
>The above was designed to work with 32 bit values. You may want to add a parameter to control how many bytes are returned and use that or modify the above.
>
>After reading your response again, I'm wondering about the program that's receiving this string. If it's in VFP couldn't you just send the original value of what created the binary string, and let the receiving program determine the fields using the bitwise functions?
>
>George
>
>P.S. Sorry about Wednesday, but that was one of the greatest performances under those circumstances I've ever seen.
>
>g

I have no idea what kind of machine is on the back end.....but I assume it is either a mainframe, a Unix box, or an AS/400. We are passing data back and forth to this company and I have to follow their format. This part of it is the only thing that is causing me problems. Of course, that will all change once I get the application ready for testing and the communcations between our box and theirs doesn't work.

Craig
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform