Hexadecimal constants?

Discussion in 'Questions (Windows Mobile)' started by mjcoon, Jun 17, 2008.

  1. mjcoon

    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.
  2. Erel

    Erel Administrator Staff Member Licensed User

    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).
  3. mjcoon

    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.
  4. agraham

    agraham Expert Licensed User

    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:

  5. mjcoon

    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.
  6. agraham

    agraham Expert Licensed User

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice