×

Discussion Board

Results 1 to 15 of 22

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    How to have a string array in Symbian

    Hi I am new to symbian I want to have a string array and want to use it in a for loop but dont know how to create it. Any example will help me a lot. Suppose I have three strings "Alice","Jeneffer","Christine" .How to make an array of this in Symbian. Is HBuf or TArray will do I am confused.

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: How to have a string array in Symbian

    Hi,

    You can use HBuf as well but the simple way is:

    TBuf<32> st[3];
    st[1].Copy(_L("Alice"));
    st[2].Copy(_L("Jeneffer"));
    st[3].Copy(_L("Christine"));

    for(TInt i=0; i<3; i++)
    {
    use st[i]...
    }


    hope this will help you. You can use HBuf also.
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: How to have a string array in Symbian

    I would use CDesCArray's like CDesCArrayFlat would be nice for the purpose.

  4. #4
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: How to have a string array in Symbian

    Hi Nikita,

    You can use CDesCArray or CArrayFixFlat<TDesC> or RPointerArray<TDesC>. Just go through the wiki examples for how to use the dynamic arrays or go through the example in SDK: Examples\Base\ArraysAndLists

    Thanks,
    Eswar

  5. #5
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    Re: How to have a string array in Symbian

    Thanks guys I have solved my problem.

  6. #6
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    Re: How to have a string array in Symbian

    Sorry to disturb you again guys...but can you help me on this..

    As you have guided me how to create an array of strings and use them in a for loop can you help me how to use enumsin the same way.

    Suppose I have an enum

    HTML Code:
    enum abc{
    EHello,
    EHi,
    EHiHello
    };
    Now how can I use it in the for loop.

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: How to have a string array in Symbian

    I would prefer CDesCArray or CArrayFixFlat, if frequently modification in string is not required. If strings in array need to be updated/deleted/removed frequently then i would prefer RPointerArray.

  8. #8
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    58

    Re: How to have a string array in Symbian

    Quote Originally Posted by kkrish View Post
    Hi,

    You can use HBuf as well but the simple way is:

    TBuf<32> st[3];
    st[1].Copy(_L("Alice"));
    st[2].Copy(_L("Jeneffer"));
    st[3].Copy(_L("Christine"));

    for(TInt i=0; i<3; i++)
    {
    use st[i]...
    }


    hope this will help you. You can use HBuf also.
    It is a bit disappointing that the use of C style arrays should be recommended by a FNC, they should be avoided in general in Symbian, and in particular as has been mentioned there are descriptor specific arrays which should be used in preference.

  9. #9
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: How to have a string array in Symbian

    yep, I agree that the CDesCArray options I suggested in the 3rd post would be better than TBuf arrays.. Anyway, people can do it anyway they want to..

  10. #10
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Re: How to have a string array in Symbian

    Quote Originally Posted by kkrish View Post
    Hi,

    You can use HBuf as well but the simple way is:

    TBuf<32> st[3];
    st[1].Copy(_L("Alice"));
    st[2].Copy(_L("Jeneffer"));
    st[3].Copy(_L("Christine"));

    for(TInt i=0; i<3; i++)
    {
    use st[i]...
    }


    hope this will help you. You can use HBuf also.
    I tried to use it but it says--"undefined identifier st". why??? another thing shoul i start from st[1] or st[0] ??

  11. #11
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: How to have a string array in Symbian

    I would still suggest on using CDesCArray.

  12. #12
    Registered User
    Join Date
    Dec 2009
    Posts
    339

    Re: How to have a string array in Symbian

    Quote Originally Posted by Md. Kayesh View Post
    I tried to use it but it says--"undefined identifier st". why??? another thing shoul i start from st[1] or st[0] ??
    Check whether you have include necessary header files or not. Should start from st[0]

Similar Threads

  1. How do we send and receive string array via bluetooth in J2ME
    By rahulkrishna in forum Mobile Java General
    Replies: 2
    Last Post: 2009-06-04, 01:50
  2. A question about String Literal in Symbian
    By AllenZhu in forum Symbian
    Replies: 1
    Last Post: 2009-05-26, 10:48
  3. Replies: 2
    Last Post: 2008-02-19, 07:15
  4. Symbian and non Symbian J2ME
    By thongtom in forum Mobile Java General
    Replies: 2
    Last Post: 2005-06-28, 10:52
  5. Replies: 1
    Last Post: 2003-12-19, 19:48

Posting Permissions

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