Forum Discussion

steve_hall's avatar
steve_hall
Contributor
13 years ago

FindAllChildren - how can I....

Does anyone know if it's possible to do something like this:




  var PropArray = Array ("Caption", "Visible", "ObjectType");


  var ValArray = Array (fieldname, "True", "Client||Edit");


  var allFields = Sys.Process("xxx").form("yyy").Client("zzz").Client("aaa").FindAllChildren(PropArray,ValArray, 5);



ie, for one of the 3 property filters, search for objects matching either of  *2* different values?



ie...


  var PropArray = Array ("Caption", "Visible", "ObjectType");


  var ValArray = Array (fieldname, "True", "Client");


  var allFields = Sys.Process("xxx").form("yyy").Client("zzz").Client("aaa").FindAllChildren(PropArray,ValArray, 5);



returns one set of objects, and




  var PropArray = Array ("Caption", "Visible", "ObjectType");


  var ValArray = Array (fieldname, "True", "Edit");


  var allFields = Sys.Process("xxx").form("yyy").Client("zzz").Client("aaa").FindAllChildren(PropArray,ValArray, 5);




returns another - but I want both sets of objects as a single set.....





??



2 Replies

  • Something like




    function findUnion(baseComponent, Props, Values, depth) {


        var unionValues = Values.pop().split("|"), unionValue, u = 0, founds = [],


            foundCheck = {}, found, f = 0, result = [];


        while (unionValue = unionValues[u++]) {


            founds = founds.concat((new VBArray(baseComponent.FindAll(Props, Values.concat(unionValue), depth, true))).toArray());


        }    


        while (found = founds[f++]) {


            if (!foundCheck[found.FullName]) {


                foundCheck[found.FullName] = true;


                result.push(found);


            }            


        }


        return result;


    }


     


    //usage:

    findUnion(AUT.MainWindow.OpenTab.Composite.Composite.Composite.PropertiesComposite,


                ["VisibleOnScreen", "WndClass"], 


                [true, "Static|Edit"], 10


            );  





    Note that I had to use FindAll rather than FindAllChildren. If a call to FAC returns nothing, then subsequent call also come up empty even if the child objects are there (TC 8.60)

  • I did not see something like you are asking for. I think you need to write the function to combine two search results into one array skipping duplicated objects by comparing their FullName property.