Hexadecimal constants?

mjcoon

Well-Known Member
Licensed User
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.
 

mjcoon

Well-Known Member
Licensed User
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.
 

agraham

Expert
Licensed User
Longtime User
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.
 

Attachments

  • BytesConverterPreview.zip
    11.7 KB · Views: 196

mjcoon

Well-Known Member
Licensed User
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.
 
Top