Simple hex to byte question (REALbasic network user group Mailinglist archive)
Back to the thread list
Previous thread: Cursor editor for Mac OS
Next thread: Re: Dealing with multi-processor or multi-core
| Simple hex to byte question |
| Date: 01.06.08 10:25 (Sun, 1 Jun 2008 19:25:35 +1000) |
| From: James Mullins |
|
Hi guys,
I am trying to program for a piece of lab equipment. What I am trying to do is convert a string that contains a hex value eg "A0" to a byte so that I can chrb it. Ie: in the past I do this: dim input as byte input phA0 tcpsocket1.write chrb(input) The problem is I now have A0 stored as a string and need to convert from the string to a single byte. Any quick ways of doing this? My brain seems to be fried! Best, James _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Simple hex to byte question |
| Date: 01.06.08 10:55 (Sun, 01 Jun 2008 19:55:34 +1000) |
| From: Tom Benson |
|
Seems non intuitive.. but you can do this as follows:
dim v as variant v w&h" + "A0" //replace the second string literal with you Hex code tcpsocket1.write chrB(v.integerValue) Cheers, Tom On 01/06/2008, at 7:25 PM, James Mullins wrote: > Hi guys, > > I am trying to program for a piece of lab equipment. > > What I am trying to do is convert a string that contains a hex value > eg "A0" to a byte so that I can chrb it. > > Ie: > > in the past I do this: > > dim input as byte > > input whA0 > tcpsocket1.write chrb(input) > > The problem is I now have A0 stored as a string and need to convert > from the string to a single byte. > > Any quick ways of doing this? My brain seems to be fried! > > Best, > > James > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > Search the archives: > <http://support.realsoftware.com/listarchives/lists.html> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Simple hex to byte question |
| Date: 01.06.08 13:50 (Sun, 1 Jun 2008 22:50:44 +1000) |
| From: James Mullins |
|
Thanks Tom,
Your right, just doesn't seem right! All the best, James On 01/06/2008, at 7:55 PM, Tom Benson wrote: > Seems non intuitive.. but you can do this as follows: > > dim v as variant > > v h&h" + "A0" //replace the second string literal with you Hex code > > tcpsocket1.write chrB(v.integerValue) > > Cheers, > Tom > > On 01/06/2008, at 7:25 PM, James Mullins wrote: > >> Hi guys, >> >> I am trying to program for a piece of lab equipment. >> >> What I am trying to do is convert a string that contains a hex value >> eg "A0" to a byte so that I can chrb it. >> >> Ie: >> >> in the past I do this: >> >> dim input as byte >> >> input ohA0 >> tcpsocket1.write chrb(input) >> >> The problem is I now have A0 stored as a string and need to convert >> from the string to a single byte. >> >> Any quick ways of doing this? My brain seems to be fried! >> >> Best, >> >> James >> _______________________________________________ >> Unsubscribe or switch delivery mode: >> <http://www.realsoftware.com/support/listmanager/> >> >> Search the archives: >> <http://support.realsoftware.com/listarchives/lists.html> > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > Search the archives: > <http://support.realsoftware.com/listarchives/lists.html> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Simple hex to byte question |
| Date: 01.06.08 13:52 (Sun, 1 Jun 2008 06:52:05 -0600) |
| From: Joe Strout |
|
On Jun 1, 2008, at 3:55 AM, Tom Benson wrote:
> Seems non intuitive.. but you can do this as follows: > > dim v as variant > v c&h" + "A0" //replace the second string literal with you Hex code > tcpsocket1.write chrB(v.integerValue) Or more simply, use Val, but with the same "&h" trick: tcpsocket1.Write ChrB( Val( "&h" + "A0" ) ) Best, - Joe |
| Re: Simple hex to byte question |
| Date: 03.06.08 04:56 (Mon, 2 Jun 2008 23:56:11 -0400) |
| From: Dave Shirk |
|
Joe,
Is there also a simple 'byte -> hex character string' method, or is it just grunting it out with the bitwise ops? Thanks, Dave Shirk Oriental, NC On Jun 1, 2008, at 8:52 AM, Joe Strout wrote: > Or more simply, use Val, but with the same "&h" trick: > > tcpsocket1.Write ChrB( Val( "&h" + "A0" ) ) > > Best, > - Joe _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Simple hex to byte question |
| Date: 03.06.08 05:06 (Mon, 2 Jun 2008 22:06:39 -0600) |
| From: Joe Strout |
|
On Jun 2, 2008, at 9:56 PM, Dave Shirk wrote:
> Is there also a simple 'byte -> hex character string' method Sure, that'd be Hex. To recap: Format, Str, Hex, Oct, and Bin convert a number to a string in various ways. Val converts a string representation of a number (in any base, with the appropriate prefix) back into a number. Best, - Joe |
| Re: Simple hex to byte question |
| Date: 03.06.08 05:08 (Tue, 3 Jun 2008 00:08:40 -0400) |
| From: Dave Shirk |
|
Duh Me!
Sometimes I just need to get stupid ;-) Thanks Joe - Dave On Jun 3, 2008, at 12:06 AM, Joe Strout wrote: > Sure, that'd be Hex. To recap: > > Format, Str, Hex, Oct, and Bin convert a number to a string in > various ways. > Val converts a string representation of a number (in any base, with > the appropriate prefix) back into a number. > > Best, > - Joe _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Simple hex to byte question |
| Date: 03.06.08 09:38 (Tue, 3 Jun 2008 18:38:56 +1000) |
| From: James Mullins |
|
Don't worry Dave,
I have had plenty of stupid moments on this list. It seems I often spend hours on a problem (usually late at night), give up trying to solve it and ask the list, only to solve it 5 minutes later. This list is such a great resource though! Keep up the good work guys. Now, if I could only find someone with COM object interface experience...... best, James On 03/06/2008, at 2:08 PM, Dave Shirk wrote: > Duh Me! > > Sometimes I just need to get stupid ;-) > > Thanks Joe - Dave > > On Jun 3, 2008, at 12:06 AM, Joe Strout wrote: > >> Sure, that'd be Hex. To recap: >> >> Format, Str, Hex, Oct, and Bin convert a number to a string in >> various ways. >> Val converts a string representation of a number (in any base, with >> the appropriate prefix) back into a number. >> >> Best, >> - Joe > _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
Links
MBS Realbasic Chart Plugins - JUZ Nickenich