×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Smile Find a particular variable position in RArray

    hi...
    Code:
    class TDemo
    {
       TInt Id;
       TBuf<20> Name;
    }
    normally v use Find like this:
    Code:
    TDemo tdemo = {2,_L("xyz")};
    RArray<TDemo> array;
    TInt pos = array.Find(tdemo);
    but i want to only find the position of Id...
    i mean i wanna only pass 1 variable out of 2 for searching the position..
    is it possible?
    how to code it?

    Thanks..
    Nital

  2. #2
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Red face Re: Find a particular variable position in RArray

    actually i wanna do something like...

    pass 1 variable, find its position & retrieve the rest of the variables from that position.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Find a particular variable position in RArray

    Actually that is what already happens:
    Quote Originally Posted by SDK Help
    Finds the first object in the array which matches the specified object using a sequential search.

    Matching is based on the comparison of a TInt value at the key offset position within the objects.
    My guess is that you have not specified an explicit key offset, thus
    Quote Originally Posted by SDK Help
    inline RArray();
    Description
    Default C++ constructor.

    This constructs an array object for an array of type class T objects with default granularity and key offset value. The default granularity is 8 and the defaul key offset value is zero.
    And your "TInt Id" is on the 0th offset.

  4. #4
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Smile Re: Find a particular variable position in RArray

    Thanks for replying...

    can u plz guide how to code dat in my example?
    i mean how to specify the key offset?

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Find a particular variable position in RArray

    Quote Originally Posted by nital_shah View Post
    can u plz guide how to code dat in my example?
    Your example already does that. Although you have to pass a complete TDemo object to Find, the content of "Name" (should be iName) is ignored, so in your code Find is searching for Id=2 only (should be iId).
    i mean how to specify the key offset?
    Read the documentation of RArray, and check its various constructors. But for your current use case the default behaviour is already fine.

  6. #6
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Smile Re: Find a particular variable position in RArray

    Originally Posted by SDK Help
    inline RArray();
    Description
    Default C++ constructor.

    This constructs an array object for an array of type class T objects with default granularity and key offset value. The default granularity is 8 and the defaul key offset value is zero.
    i got it dat in my example TInt iID is at 0th offset so it is defaultly found..

    but wat if i wanna search on basis of TBuf which is on 1st offset..?

    if i put it in constructor like RArray<Txxx> array(8,1), it doesnt allow me to append values & panics..

    i just wanna use this to find the position..
    so hw to do dat?

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Find a particular variable position in RArray

    You can get the panic code in the usual way. But reading the documentation also helps
    Quote Originally Posted by SDK Help
    inline RArray(TInt aGranularity, TInt aKeyOffset);
    Description
    C++ constructor with granularity and key offset.

    This constructs an array object for an array of type class T objects with a specified granularity and a specified key offset value.

    Parameters
    TInt aGranularity The granularity of the array.

    TInt aKeyOffset The key offset.



    Panic codes
    Unfortunately I have removed the table from here, but you can find it in the SDK Help.

Similar Threads

  1. not able to get Latitude & Longitude values
    By smita.pawar in forum Symbian
    Replies: 7
    Last Post: 2008-10-08, 11:05
  2. Problem changing position of a CEikTextListBox
    By Ishibo San in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-08-25, 15:54
  3. Use global variable in s3rd
    By andrew_lin in forum Symbian
    Replies: 6
    Last Post: 2008-05-03, 11:53
  4. Replies: 4
    Last Post: 2008-04-18, 11:07
  5. How to Createan RArray with a key Order?
    By Rozik in forum Symbian
    Replies: 0
    Last Post: 2007-09-05, 09:22

Posting Permissions

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