Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

binary variable

Status
Not open for further replies.

spokex

Programmer
Jul 26, 2002
17
0
0
US
I need to communicate via mscomm with a digitizer. According to the manufacturer if I send a binary 00000001 it will return three 8 bit bytes of data.

Foxpro and Mscomm I have experience with but coding for binary is new to me.

Thanks

Scott
 
Hi,

A binary 000001 is just a character with only the first bit set - so you can send it by just using a CHR(1) if you want.

Martin

Regards

Griff
Keep [Smile]ing
 
I was trying to make it much more complicated.

Thanks

Scott
 
When the binary bytes are recieved from the device, what is the best way to convert them into an integer?

Scott
 
For small numbers - up to 254
Code:
asc(mybyteshere)

When you need something bigger, you will need to know which byte(s) are the most significant and multiply that one by 255 and add in the other one.

i.e. if the first byte is the most significant in a two byte pair:
Code:
myInteger = (Asc(myFirstByte) * 255)  + Asc(mySecondByte)

Do you follow?




Regards

Griff
Keep [Smile]ing
 
I have that wrong, if one byte takes you to 255 (FF) and then the next one would be 256, so you have to multiply the most significant byte in a two byte pair by 256 (sorry)

Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top