×

Discussion Board

Results 1 to 3 of 3

Thread: RFile

  1. #1
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    RFile

    Can't i write a integer to RFile, if i can how??.I get confused with the way symbian handles char & int manipulation with all hbuf, tdes ..don't even understand what to use when & how..plz clarify someone.

    Thanks
    Later
    Dips

    Posted by Dips M, contactwithdeepa@hotmail.com
    on April 30, 2002 at 13:06

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    RE: RFile

    Posted by Forum_Nokia Developer_Support, communicator.developer@nokia.com
    on April 30, 2002 at 13:55



    You mind find it easiest to write to an RFile using RFileWriteStream, you can then use the RWriteStream functions such as WriteInt32L() to write to the RFile. RFileWriteStream can take an existing opened RFile object or you can open an existing filename

    Alternatively you could just use:

    TInt myInt;
    TPtrC8 buf((TText8*)&myInt,sizeof(TInt));
    rfile.Write(buf);

    to write the 4 bytes in the integer to the file. But if you are writing to a text file and want the number to appear as text then use:

    TBuf8<8> num;
    num.Num(myInt);
    rfile.Write(num);

    which converts the integer to a string and writes it to the file

    Regards,
    FN Developer Support

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    RE: RFile

    Posted by Asheesh Sangamneheri, asangamneheri@hotmail.com
    on April 30, 2002 at 13:58



    hi dips,

    you have to use TLex to convert string to numbers and vice versa. the code below reads 3 chars from a file and converts it to a number.

    RFs fsSession;
    fsSession.Connect();
    RFile myFile;

    TBuf8<3> read3; // need TBuf8 to read file
    TLex8 conv;
    TInt number;

    ReadFile.Open(fsSession,myFile,EFileRead);
    {
    ReadFile.Read(read3); // TBuf8
    conv=read3; //use TLex8 to convert
    conv.Val(number); // number=conv=read3
    }

Posting Permissions

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