Solved

Search TList

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

Type

   TRecord = ^TCard;

   TCard = packed record

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


end;


   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)?
0
Comment
Question by:foxjax
[X]
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
4 Comments
 
LVL 27

Expert Comment

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

just from head, just as sample

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 11928844
sorry a typo

instead of

TRecord.name
use
TRecord(groups[i]).name

also for the item section

meikl ;-)
0
 
LVL 27

Accepted Solution

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

TRecord(groups[i])^.name

just no time for testing

meikl ;-)

0
 

Author Comment

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

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

636 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