I want to proceed by removing nodes. Each time the keyword changes, I will remove the node again. For example, in JSL, the first keyword is 1, then it changes to 2, but it always ends up with an error. Why is that? According to this logic, how should I correct it?
Names Default To Here(1);
root1 = Tree Node("Parent 1");
root2 = Tree Node("Parent 2");
c1 = Tree Node("Child 1");
c2 = Tree Node("Child 2");
c3 = Tree Node("Child 11");
c4 = Tree Node("Child 4");
root1 << Append(c1);
root1 << Append(c2);
root2 << Append(c3);
root2 << Append(c4);
nw = New Window("TreeBox",
vlb = V List Box();
);
search_term = " 1";
tree = Tree Box({root1, root2}, Size(300, 200));
tree << Expand(root1);
tree << Expand(root2);
treeDuplicate=tree;
For Each({root}, treeDuplicate << get roots,
is_hidden = 1;
For(i = 1, i <= root << Get Child Count, i++,
cur_child = root << get child(i);
If(Contains(cur_child << get label, search_term),
is_hidden = 0;
,
cur_child << remove;
);
);
If(is_hidden,
treeDuplicate << Collapse(root);
,
treeDuplicate << Expand(root);
);
);
vlb << append(treeDuplicate );
wait(3);
treeDuplicate<< delete;
wait(3);
search_term = " 2";
treeDuplicate=tree;
For Each({root}, treeDuplicate << get roots,
is_hidden = 1;
For(i = 1, i <= root << Get Child Count, i++,
cur_child = root << get child(i);
If(Contains(cur_child << get label, search_term),
is_hidden = 0;
,
cur_child << remove;
);
);
If(is_hidden,
treeDuplicate << Collapse(root);
,
treeDuplicate << Expand(root);
);
);
vlb << append(treeDuplicate );