Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Hexadecimal constants?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2008, 11:13 AM
Junior Member
 
Join Date: May 2008
Posts: 24
Default Hexadecimal constants?

Hi, I'm setting out to replicate some parts of Psion programs that I wrote, using their version of Basic called "OPL".

Like in many languages a numeric constant could be set to a hexadecimal value by prefixing (with "$"). Is there an equivalent in Basic4PPC? (I cannot find it in Help.)

(Since I am doing binary serial data transfer with a Garmin GPS, see Psion programming projects, it would be particularly pertinent.)

Cheers, Mike.
Reply With Quote
  #2 (permalink)  
Old 06-17-2008, 11:59 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

There is no hexadecimal notation in Basic4ppc.
It will be probably added in a future version.
You can use Bitwise.HexToDec to convert hexadecimal strings to numbers (at runtime).
Reply With Quote
  #3 (permalink)  
Old 06-17-2008, 04:00 PM
Junior Member
 
Join Date: May 2008
Posts: 24
Default

Thanks Erel, I think that the addition of a hex notation would be a Good Thing.

In fact since I want a byte array initialised with hex values, HexToDec() (which returns a single number) is not really what I want. A version of StringToBytes() that copes with hex notation as well as doing the type coercion would be nearer the mark.

Similarly it is sometimes convenient to display a buffer's content as a string of hex characters, requiring the converse function.

Best regards, Mike.
Reply With Quote
  #4 (permalink)  
Old 06-17-2008, 05:58 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,757
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by mjcoon View Post
In fact since I want a byte array initialised with hex values, HexToDec() (which returns a single number) is not really what I want. A version of StringToBytes() that copes with hex notation as well as doing the type coercion would be nearer the mark.

Similarly it is sometimes convenient to display a buffer's content as a string of hex characters, requiring the converse function.
I must be a mind reader. My next library, about to be posted when I have finished testing, may do what you want. It will be, I think, be a bit esoteric for most but it will do individual datatype to byte array and back conversions, including byte data represented as Hex strings.

Here's a preview to play with.
Attached Files
File Type: zip BytesConverterPreview.zip (11.7 KB, 13 views)
Reply With Quote
  #5 (permalink)  
Old 06-18-2008, 10:20 AM
Junior Member
 
Join Date: May 2008
Posts: 24
Default

Thank you Andrew, I shall certainly have a play with that.

Also because it may help me to resolve a persistent problem that I am having with this serial program of mine. While I can exchange text characters OK, even if I receive them as binary, if I try to send and receive binary the bytes do not come out as I expect...

Regards, Mike.
Reply With Quote
  #6 (permalink)  
Old 06-19-2008, 12:48 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,757
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Release quality BytesConverter library now available in ByteConverter library
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
color constants slightly off their readback value colin9876 Bug Reports 6 12-11-2007 07:26 PM


All times are GMT. The time now is 02:37 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0