×

Discussion Board

Results 1 to 6 of 6

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    61

    Array in symbian

    Hi all,
    I want to store some data like "hello", "hello1","hello2","hello3" in an array. Such that "hello" is the first element of the array, "hello1" is the second element and so on. I want to retrieve these data in a for loop just like we do in c++... something like
    for(int i =0; i<array.length;i++)
    {
    cout << array[i]<< endl;

    }
    actually i want to display the data inside the array inside a rectangle using draw text. How can i initialize the array and retrieve the elements from it.

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    19

    Re: Array in symbian

    Hi,

    You can use CDesCArray to store descriptor type data. If you want to insert text items into it, can use AppendL() method.

    For getting the no. of elements in the array, can use Count() method.
    For traversing through the array, use At() or Operator[]() methods passing the index.
    Refer the SDK on CDesCArray for more details.

    Cheers,
    Vijay M

  3. #3
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Banglore,India
    Posts
    156

    Re: Array in symbian

    Quote Originally Posted by Shweta.Hegde View Post
    Hi all,
    I want to store some data like "hello", "hello1","hello2","hello3" in an array. Such that "hello" is the first element of the array, "hello1" is the second element and so on. I want to retrieve these data in a for loop just like we do in c++... something like
    for(int i =0; i<array.length;i++)
    {
    cout << array[i]<< endl;

    }
    actually i want to display the data inside the array inside a rectangle using draw text. How can i initialize the array and retrieve the elements from it.
    Hi, You can use
    CDesCArrayFlat;
    create a pointer object allocate memory through new operator;
    And insert item into array through AppendL() method;
    And retrieve the item through ->operator[]();

  4. #4
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    108

    Re: Array in symbian

    Hi,
    You can use CDesCArrayFlat.
    see this code:-

    CDesCArrayFlat* array=new (ELeave)CDesC16ArrayFlat(5);

    TBuf<20> data1;
    TBuf<20> data2;
    TBuf<20> data3;

    data1=_L("hello");
    data2=_L("hello1");
    data3=_L("hello2");

    array->AppendL(data1);
    array->AppendL(data2);
    array->AppendL(data3);
    you can retrieve elements by giving " (*array)[i] " in a for loop.
    or you can retrieve the elements like this :-
    TBuf<20> retrve_data1;
    retrve_data1=(*array)[0] ;//for first element

    remesh

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    2

    Re: Array in symbian

    CDesCArrayFlat* array=new (ELeave)CDesC16ArrayFlat(5);

    TBuf<20> data1;
    TBuf<20> data2;
    TBuf<20> data3;

    data1=_L("hello");
    data2=_L("hello1");
    data3=_L("hello2");

    array->AppendL(data1);
    array->AppendL(data2);
    array->AppendL(data3);

    access each element by
    &array->operator [](0);
    &array->operator [](1);
    &array->operator [](2);

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: Array in symbian

    Note that this thread has happened a bit earlier (3+ months ago).

    Anyway, although the x->operator[](y) construct works, some may consider (*x)[y] more readable.

Similar Threads

  1. Question regarding Java vs Symbian C++
    By Olnex in forum Mobile Java General
    Replies: 5
    Last Post: 2006-09-27, 23:53
  2. Replies: 1
    Last Post: 2006-09-27, 14:19
  3. Symbian and non Symbian J2ME
    By thongtom in forum Mobile Java General
    Replies: 2
    Last Post: 2005-06-28, 10:52
  4. Replies: 2
    Last Post: 2003-08-19, 16:39
  5. setting of Series 60 MIDP SDK for Symbian OS version 1.2 for networking
    By servigo in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2003-07-31, 07:47

Posting Permissions

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