Search TList

Posted on 2004-08-29
Last Modified: 2010-08-05
I have a TList that is used to store records


   TRecord = ^TCard;

   TCard = packed record

           Item           : Integer;
           Name           : String;
           Limit          : Boolean;
           Period         : String;


   Group  : TList;
   Record : TRecord;

Question - how can i search through each of the records for an item number or a name and return the record number ( ie: user can search by using an item number or the name of a product)?
Question by:foxjax
  • 3
LVL 27

Expert Comment

ID: 11928816
function findrecord(sType : Integer; sName : String; sNumber : Integer) : Integer;
var i : integer;
  i := 0;
  case sType of
    1 : begin  //search by name
            while (i < group.count) and ( <> sName) do inc(i);
    2 : begin  //search by item
            while (i < group.count) and (TRecord.item<> sNumber) do inc(i);
  if (i < group.count) then
    result := i
    result := -1

just from head, just as sample

meikl ;-)
LVL 27

Expert Comment

ID: 11928844
sorry a typo

instead of

also for the item section

meikl ;-)
LVL 27

Accepted Solution

kretzschmar earned 200 total points
ID: 11928846
maybe it must be


just no time for testing

meikl ;-)


Author Comment

ID: 11928912
TRecord(groups[i])^.name made it work - thanks Meikl, i learned a lot from that.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 117
Printing problem 2 79
Delphi XE10 Round Image 2 75
Error E2158 compiling with Delphi XE10 Seattle 2 83
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now