Forum Discussion

rushikesh's avatar
rushikesh
Contributor
6 years ago

Type of Array is changing from object to COMSafeArray when copy code from one project to other.

Hi,

 

I am using below code to get details of buttons present in a dialog box.

 

function inGetData(page)
{

Buttons = new Array();

Buttons = GetChildren("Button",page);

 

}

 

function GetChildren(WndClass,Page)
{
  //gets all children of a particular class on a particular page
  //the page must exist
  if(!(Page.Exists))
  {
    Log.Error("Page does not exist");
    return null;
  }
  ChildArray = Page.FindAllChildren("WndClass", WndClass, 5);
  ChildArray = (new VBArray(ChildArray)).toArray();
  return ChildArray;
}

 

1. When call function inGetData() and check type of ChildArray, it is Object type. Also, i can accesss properties of contents of Array. Refer image 1.png

 

2. Now i copy same code in another project.

However when call inGetData() type of ChildArray changes to COMSaveArray and I cannot access prperties of contents of Array. Refer image 2.png.

 

What's happenning in second case.

And how to solve it.

 

In both projects JavaScript is used.

 

 

 

 

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    If you're using JavaScript and not JScript the following line is not necessary.

     

    ChildArray = (new VBArray(ChildArray)).toArray(); 

     

    Try removing that line.