Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

TList.sort

edited December 2006 in RAP
I'm trying to call the "sort" method on a TList object in my RAP code but
the compiler doesn't like it. Is the "sort" member exposed to RAP? If not,
then what TraTppxxxRTTI object do I need to descend from to expose it
myself.

I'm using version 10.04

Paul

Comments

  • edited December 2006
    AFAIK because TList doesn't deend from TPersistent but TObject, you can not
    do that. You need to create your own via a pass-through function.

    HTH,
    Ed Dressel
    Team DM
  • edited December 2006
    Sorry, I don't understand: if TList is exposed to RAP, along with some of
    its methods list Add(), why can't I just expose Sort() as well? My Tlist is
    created dynamically so I'm not sure what persistance has to do with it. Or
    maybe I'm missing something fundamental here?

    Thanks, Paul



  • edited December 2006

    - One option is to use a TStringList. TStringList includes support for Sort
    and enables you to store a string and associated object.

    - RAP RTTI support for TList is defined in raObjectRTTI, the class name is
    TraTListRTTI. The TList.Sort method requires that a call back function be
    passed as a parameter - the callback function performs the item Comparisons.
    You cannot pass a RAP function as a callback - so it is not going to work.
    (You could probably descend from TList and create a DoSort method that does
    not require the callback function).


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2006
    Thanks Nard

    It has to be a Tlist because I need to sort on any number of fields in then
    objects (of the same class) that it is listing. I'll look into descending a
    TList with a range of sort methods, but surely I would then need to
    re-implement the exposing of this new class to RAP, which is going to
    replicate all of what you have already done with TList and RAP? If so then
    are there any gotchas or minimum requirements,? I ask because you don't make
    raObjectRTTI.pas available for me to consult/copy.


    Paul

  • edited December 2006

    I just emailed you the TraTListRTTI source code.

    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com\

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2006
    Nard, top draw support again, many thanks. I'm stretching the envelope a bit
    with RB at the moment but I'm regularly astonished by how far I can take it.
    I've 10 yrs experience of having to work with Crystal Reports and if I were
    forced to do some of the stuff I'm doing in RB at the moment in CR I'd have
    to hold me head in my hand and weep! Keep it up :)

    Paul


This discussion has been closed.