Well, he wants to throw in a %match, so that wouldn't do it.-wraith808
Now i've understood, thank you for explaining to me!
Here is theory on how to do that, simple range check.
- checker code
function IsInRange(MinValue, MaxValue: double): Boolean;
var
Count: Integer;
begin
Result := False;
for count := 0 to BigList.NumberOfItems -1 do
if ((BigList.Items[Count].Value >= MinValue) or (BigList.Items[Count].Value <= MaxValue)) then
begin
Result := True;
Exit;
end;
end;
- maincode
for Count := 0 to Masterlist.NumberOfItems -1 do
begin
MinValue := Calculate( MasterList.Items[Count].Value -5% )
MaxValue := Calculate( MasterList.Items[Count].Value +5% )
if IsInRange(MinValue, MaxValue) then
CompareListResults.AddNewItem := Count;
end;
In that sample the MasterList should be the List with less Items than BigList.
I hope you now get an Idea on how to solve this.
Since its just proto-code, it give only first match from criteria MinValue and MaxValue back.
Edited this way it will grab all Matches from BigList
- checker code
procedure SaveRanges(MinValue, MaxValue: double; var SavedList: TList);
var
Count: Integer;
begin
Result := False;
for count := 0 to BigList.NumberOfItems -1 do
if ((BigList.Items[Count].Value >= MinValue) or (BigList.Items[Count].Value <= MaxValue)) then
SavedList.Items.Add( IntToStr(Count) );
end;
- maincode
NewList := TList.Create();
for Count := 0 to Masterlist.NumberOfItems -1 do
begin
MinValue := Calculate( MasterList.Items[Count].Value -5% )
MaxValue := Calculate( MasterList.Items[Count].Value +5% )
SaveRanges(MinValue, MaxValue, NewList);
end;
This sample would hold all matches in NewList.
Edited this way it will grab all Matches from BigList and Save callers Index within
- checker code
procedure SaveRanges(const MinValue: double; const MaxValue: double; const CallerIndex: Integer; var SavedList: TList);
var
Count: Integer;
begin
Result := False;
for count := 0 to BigList.NumberOfItems -1 do
if ((BigList.Items[Count].Value >= MinValue) or (BigList.Items[Count].Value <= MaxValue)) then
SavedList.Items.Add( IntToStr(CallerIndex) + ' found match with ' + IntToStr(Count) );
end;
- maincode
NewList := TList.Create();
for Count := 0 to Masterlist.NumberOfItems -1 do
begin
MinValue := Calculate( MasterList.Items[Count].Value -5% )
MaxValue := Calculate( MasterList.Items[Count].Value +5% )
SaveRanges(MinValue, MaxValue, Count, NewList);
end;
This sample would hold all matches in NewList, ready to use with matches display.
Ps: If you are confused of line "for Count := 0 to Masterlist.NumberOfItems -1 do", adjust this to your Language.
In Delphi Lists Index begin at "0" and NumberOfItems at "1". NumberOfItems "0" would mean Index "-1" (no item exist in List)