foxjax
asked on
Search TList
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)?
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)?
sorry a typo
instead of
TRecord.name
use
TRecord(groups[i]).name
also for the item section
meikl ;-)
instead of
TRecord.name
use
TRecord(groups[i]).name
also for the item section
meikl ;-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
TRecord(groups[i])^.name made it work - thanks Meikl, i learned a lot from that.
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 ;-)