Forum Discussion

ChandanD's avatar
4 years ago

Add value in Array from FindAllChildren



I want to add the values in array from FindAllChildren and then find the Maximum value from array and perform the action on the max value.

But I am unable to enter the value in array and get the max value.


Please help to add the value in array and fetch the values from array.


var AllSelectCID = IBCDesigner.HwndSource_Window.WindowDeviceVersionSelection.TabControlSWVersionSettings.FindAllChildren(Array("ClrClassName","WPFControlOrdinalNo"), Array("CellValuePresenter", "2"), 100)
    var max = []
    for (var SelectCID of AllSelectCID)
      Visible_Index = SelectCID.DataContext.VisibleIndex
      var max = Visible_Index[0]
    for (let i = 0; i < Visible_Index.length; ++i) {
  if (Visible_Index [i] > max) {
    max = Visible_Index [i];
    Log.Message("The complete array is"+ max)


3 Replies

    • tphillips's avatar
      Frequent Contributor



      You're declaring max as an array on line 2, then you're redeclaring it as a regular variable on line 7. This is likely causing issues

      You're also never appending to your max array. What is your intention with that array anyway?


      Additionally, you're mixing up your use of 'let' and 'var', and you're never declaring Visible_Index.

      • ChandanD's avatar

        What I am trying to achieve is :

        I want to click on Radio button. The list of radio button is updated as per selected software version. (Eg. SW version 1  has 3 radio button, SW version 2 has 2 radio buttons). I am unaware of the list. 

        So, the logic I am using is to find the latest index from array and click on the radio button. 

        Now, with FindAllChildren I am finding out the latest index. I want to add the index number in Array and then find the maximum value from array and click on the Radio button with max index number. 


        So, how to add the index number into array.