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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 188
Delphi inherited method 6 80
Is there any way to treat Lock record in table with clientdataset? 3 32
TlistView is Really heavy on Android 3 22
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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