×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    20

    Help! How to read and write Hex value to a position of a file?

    Hi,

    I have a problem down here and hope someone here can tell me how to.

    I need to read and write data in hex to a file at a specifice position.

    e.g. write a hex value of 100 to position 20 of a file.

    or is there a way to use seek or seekL to move my file pointer to a position and use write16L to write my data?

    Thank a lots

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    take a look at RFile.

    With it you could just use one of the variants of Write()-function, just put the hex number in TBuf8 buffer and write it to right location in the file.

    yucca

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    20
    Thanks for your help.
    Maybe i have express wrongly.
    But that will only print the value as text.
    e.g. a value "1234" will be printed as "4d2"..
    but this is not the result i want...
    i will need to have it printed as long or int value same as what write16L will print.( binary value).

    thanks again.

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    you could do it quite easily really.

    just define the TBuf8<XX> Buf; and set the values byte by byte like this:

    TInt MyValue = 0xFd;

    Buf[i] = (char)MyValue;

    and then just write the string to your file.

    yucca

  5. #5
    Registered User
    Join Date
    Jan 2004
    Posts
    20

    Thanks

    Yes It works.
    Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •