This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.
PdupeTreeData = ^TdupenodeData;
Tdupenodedata = record
number : string;
name : string;
country : string;
end;
var
i1, i2: Integer;
mytreedata1,mytreedata2 : PVirtualNode;
x : integer;
my1 : PdupeTreeData;
my2 : PdupeTreeData;
dupetree.beginupdate;
Node1 := dupetree.GetFirst;
while Node1<>nil do
begin
my1 := dupetree.GetNodeData(Node1);
Node2 := dupetree.GetNext(Node1);
while Node2<>nil do
begin
my2 :=dupetree.GetNodeData(Node2);
if my1.name = my2.name then
begin
temp := dupetree.getnext(Node2);
dupetree.isvisible[node2]:=false ;
Node2:=temp;
end else
Node2 := dupetree.GetNext(Node2);
end;
Node1 := dupetree.GetNext(Node1);
end;
dupetree.Endupdate;
Do more with
var
Node1, Node2 : PVirtualNode;
n, m : integer;
my1 : PdupeTreeData;
my2 : PdupeTreeData;
found: TStringList;
dupetree.beginupdate;
try
found := TStringList.Create;
try
Node1 := dupetree.GetFirst;
while Node1<>nil do
begin
my1 := dupetree.GetNodeData(Node1);
// first add all duplicates to the list
found.clear;
found.AddObject(my1.country, Node1);
Node2 := dupetree.GetNext(Node1);
while Node2<>nil do
begin
my2 := dupetree.GetNodeData(Node2);
if my1.name = my2.name then
found.AddObject(my2.country, Node2);
Node2 := dupetree.GetNext(Node2);
end;
// now process the list
repeat
n := found.IndexOf('USA');
if n <> -1 then
found.Delete(n); // remove all usa
until n = -1;
n := found.IndexOf('EUR');
if n <> -1 then // hide all non EUR duplicate nodes
begin
for m := 0 to found.Count-1 do
if m <> n then
dupetree.isvisible[PVirtualNode(found.objects[m])] := false;
end; // else leave all EUR nodes visible
Node1 := dupetree.GetNext(Node1);
end;
finally
found.Free;
end;
finally
dupetree.Endupdate;
end;
procedure TForm1.FilterCountry(aCountry: string);
var
Node1, Node2 : PVirtualNode;
m : integer;
my1 : PdupeTreeData;
my2 : PdupeTreeData;
found: TStringList;
begin
dupetree.beginupdate;
try
found := TStringList.Create;
try
Node1 := dupetree.GetFirst;
while Node1<>nil do
begin
my1 := dupetree.GetNodeData(Node1);
// first add all duplicates to the list
found.clear;
found.AddObject(my1.country, TObject(Integer(Node1)));
Node2 := dupetree.GetNext(Node1);
while Node2<>nil do
begin
my2 := dupetree.GetNodeData(Node2);
if my1.name = my2.name then
found.AddObject(my2.country, TObject(Integer(Node2)));
Node2 := dupetree.GetNext(Node2);
end;
// now process the list
for m := 0 to found.Count-1 do
if found[m] <> aCountry then
dupetree.isvisible[PVirtualNode(Integer(found.objects[m]))] := false;
Node1 := dupetree.GetNext(Node1);
end;
finally
found.Free;
end;
finally
dupetree.Endupdate;
end;
end;
var n: integer;
// now process the list
n := found.IndexOf('USA');
for m := 0 to found.Count-1 do
if found[m] <> aCountry then
begin
if not ((n = -1) and (found[m]) = 'EUR')) then // only hide when no usa and not EUR
dupetree.isvisible[PVirtualNode(Integer(found.objects[m]))] := false;
end;
procedure TForm1.FilterCountry(aCountry: string);
var
Node1, Node2 : PVirtualNode;
m : integer;
my1 : PdupeTreeData;
my2 : PdupeTreeData;
found, alts: TStringList;
begin
aCountry := UpperCase(aCountry);
dupetree.beginupdate;
try
alts := TStringList.Create;
try
alts.Add('EUROPE');
alts.Add('JAPAN');
found := TStringList.Create;
try
Node1 := dupetree.GetFirst;
while Node1<>nil do
begin
my1 := dupetree.GetNodeData(Node1);
// first add all duplicates to the list
found.clear;
found.AddObject(UpperCase(my1.country), TObject(Integer(Node1)));
Node2 := dupetree.GetNext(Node1);
while Node2 <> nil do
begin
my2 := dupetree.GetNodeData(Node2);
if my1.name = my2.name then
found.AddObject(UpperCase(my2.country), TObject(Integer(Node2)));
Node2 := dupetree.GetNext(Node2);
end;
// now process the list
n := found.IndexOf(aCountry);
o := -1; // index of first country
// if non us find first alts country
if n = -1 then
for m := 0 to alts.Count-1 do
begin
o := found.IndexOf(alts[m]);
if o <> -1 then // found !
Break;
end;
// now hide everything for not country and not first alt country
for m := 0 to found.Count-1 do
if (m <> n) and (m <> o) then
dupetree.isvisible[PVirtualNode(Integer(found.objects[m]))] := false;
Node1 := dupetree.GetNext(Node1);
end;
finally
found.Free;
end;
finally
alts.Free;
end;
finally
dupetree.Endupdate;
end;
end;
Premium Content
You need an Expert Office subscription to comment.Start Free Trial