>
>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
George
Ubi caritas et amor, deus ibi est