Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor maheskumar's Avatar
    Join Date
    Dec 2010
    Posts
    87
    hello friends...
    i am confused with the bellow code
    RPointerArray<HBufC>* iDisplaycontent = new RPointerArray<HBufC>;
    HBufC* CopyText = aText.Alloc();
    iDisplaycontent->Append(CopyText);

    TInt x = iDisplaycontent->Count();
    TBuf<8> temp;
    temp.Num(x);
    log.Write(temp);

    if(iDisplaycontent->Count()> 2)
    {
    log.Write(_L("Hello World6"));
    logger->DoWrite();
    }
    my target is whenever the execution comes to the iDisplaycontent->Append(CopyText);
    line my count value should be increased ..that means the data will be appended in that location.....but the problem is whenever the data are appending onthe iDisplaycontent->Append(CopyText);
    the count value always showing ONE(1) value i dont know why ?i think the new datas are overwriting the existing data ... please anyone give correct solution for it...........i want array of data should be stored in the iDisplaycontent->append(aCopyText).

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,747
    In this form your code seems to be a single continuous piece. Assuming this version, you always create a new array, and append a single item to it. Count=1 seems to be fine though.

    More important notes:
    - R-classes should rather be used as immediate variables, like "RPointerArray<HBufC> displaycontent;"
    - RPointerArray can not properly free HBufC
    - Symbian provides dedicated string-array classes, which can properly free themselves, CDesCArray is the base class and CDesCArrayFlat/Seg are the actual types

  3. #3
    Regular Contributor maheskumar's Avatar
    Join Date
    Dec 2010
    Posts
    87
    HELLO SIR........
    then how to append the many item?

  4. #4
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,747
    Create the array only once, somewhere else...
    Since you call it iDisplaycontent, you probably wanted to have it as a member variable, for example.

  5. #5
    Regular Contributor maheskumar's Avatar
    Join Date
    Dec 2010
    Posts
    87
    sir please suggest where to create the array?...

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,747
    If you are using some CDesCArray, it should be created in ConstructL. If you are using a direct RPointerArray member variable, it is created implicitly, though you can provide it with some additional parameters in the constructor's initializer list if you want.

  7. #7
    Regular Contributor maheskumar's Avatar
    Join Date
    Dec 2010
    Posts
    87
    hello sir ,.
    now i declared RPointerArray in construct method like...iDisplaycontent= new RPointerArray<HBufC>;...even though the count value does not increased... what to do ?

  8. #8
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,747
    I can not imagine what you are doing. Show some code.

  9. #9
    Regular Contributor maheskumar's Avatar
    Join Date
    Dec 2010
    Posts
    87
    hello sir this is my code ...
    EXPORT_C void CSRMLogger::Write(const TDesC16& aText)
    {
    CSRMLogger* logger = Logger();

    HBufC* CopyText = aText.Alloc();
    if(logger)
    {
    iDisplaycontent->Append(CopyText);
    static TInt x = iDisplaycontent->Count();
    if(iDisplaycontent->Count()>2)
    {
    logger->DoWrite();
    }
    else
    {
    Logger();
    }
    }
    }
    this is the write method for log.... my target is... i dont want to write the log directly into file... instead of that first i want to store the log into buffer(Using RPointerArray)when the buffer is full then only the log should go into file in the particular drive.....for that purpose i used count() to count the no .of log in the buffer..but the count value is always ONE(1).this is my problem....please help me....

  10. #10
    Nokia Developer Champion hotcheese's Avatar
    Join Date
    Jul 2004
    Posts
    2,015
    Programming is a skill.
    But so is thinking about what the problem could be logically when you have an issue.
    What are the possibilities?
    1) There is a defect in RPointerArray itself.
    2) There is a mistake in the way you are appending things into RPointerArray.
    3) There is a mistake in the logic of your program.


    1) is unlikely seeing as this code is many many years old.

    So what to do next then?

    Well how about writing a simple bit of code to check 2).
    Why don't you create an array, then append two things to it and see what the count is. If the count is still 1, then you know you are not using it properly.
    If its 2 then you know your program's logic is incorrect.


    Teach yourself to fish.
    Last edited by hotcheese; 2011-01-11 at 05:06.

Similar Threads

  1. Counting only unread messages
    By vivek_mics in forum General Messaging
    Replies: 1
    Last Post: 2006-08-17, 08:38
  2. Email Counting
    By vivek_mics in forum Symbian C++
    Replies: 1
    Last Post: 2006-08-15, 10:50
  3. Counting the number of files in a particular folder
    By MananW in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2006-04-20, 16:41
  4. Counting Time
    By tommylkc in forum Symbian C++
    Replies: 1
    Last Post: 2003-09-22, 16:32
  5. Counting Keypad Locked/Unlocked 7210
    By sshanks2 in forum Mobile Java General
    Replies: 0
    Last Post: 2003-08-22, 16:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved