Solved

Search TList

Posted on 2004-08-29
4
266 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
Using idhttp to login to instagram 2 89
Create Database on Android via Delphi dbExpress 3 88
Correct Component for Shopping Cart. 2 104
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

815 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

9 Experts available now in Live!

Get 1:1 Help Now