Forum Discussion
Anton_A
14 years agoOccasional Contributor
Hi Jared. Your solution doesn't work the same as my previous because of wrong recursion handling. I've checked it in debug mode, it doesn't return finded node, instead it finishes loop, then post warning and return null. My suggestion is that parent FindNode() functions isn't closed by sub function's return. But i have found the solution and it is working, hope that will help somebody else:
function FindNode(treeObjs, soughtNode) {
for (var i = 0; i < treeObjs.Count; i++)
{
var node = treeObjs.Item(i);
if(SameText(node.Text.OleValue,soughtNode))
return node;
return FindNode(node.Nodes, soughtNode);
}
}
...
function VerifyNodeExists(treeObj, soughtNode) {
var node = FindNode(treeObj.Nodes, soughtNode);
if (node!=undefined )
Log.Checkpoint("Sought node '"+soughtNode+"' was found");
else Log.Warning("Couldn't find '"+soughtNode+"' node");
}
function FindNode(treeObjs, soughtNode) {
for (var i = 0; i < treeObjs.Count; i++)
{
var node = treeObjs.Item(i);
if(SameText(node.Text.OleValue,soughtNode))
return node;
return FindNode(node.Nodes, soughtNode);
}
}
...
function VerifyNodeExists(treeObj, soughtNode) {
var node = FindNode(treeObj.Nodes, soughtNode);
if (node!=undefined )
Log.Checkpoint("Sought node '"+soughtNode+"' was found");
else Log.Warning("Couldn't find '"+soughtNode+"' node");
}
Related Content
- 5 years ago
Recent Discussions
- 2 days ago