How to convert Hex values in file to number or string

Discussion in 'Questions (Windows Mobile)' started by HARRY, Feb 20, 2008.

  1. HARRY

    HARRY Active Member Licensed User


    In a file there are some (1 to 4) consequetive bytes that form together a hex value. That file results from another program, not a Basic4PPC program. I do not succeed to make calculations with that data.

    I read the relevant part of the file, opened with cRandom, into a variable. Using SubString to isolate the bytes concerned results into a message 'The XML was improperly formatted'.

    I tried several things, but no result. Am I overlooking something? What is the proper way to do that?

  2. Erel

    Erel Administrator Staff Member Licensed User

    Which version of Basic4ppc do you use?
    'The XML was improperly formatted' is an IDE bug that was fixed in V6.00.

    You should read the bytes with FileGetByte or with the BinaryFile library.
    Afterwards you will need to do a small calculation to get the number value.
    Something like (if the value is written in two bytes and the first byte is the lower byte):
    b1 = FileReadByte(c,pos)
    b2 = FileReadByte(c,pos+
    number = b1 + 
    256 * b2
  3. HARRY

    HARRY Active Member Licensed User


    Thanks for your support. I use version 6.01

  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