Forum Discussion

warnerbrothers1's avatar
warnerbrothers1
New Contributor
11 months ago

Is there any way to pass array of custom class objects from delphi to testcomplete?

I need to get an array (or TList, or something else) of custom class objects from a Delphi-method to TestComplete.
For example, there is a method in Delphi:

type TMyArray = array of TMyClass;
...
function GetArrayOfMyClass: TMyArray;


I need to get the result of the function in TesComplete (js):

let obj = Sys.Process...MyObj;
let myArray = obj.GetArrayOfMyClass();


, but on the last line I get an error

"An exception occurred: 0xC0000005; class: ; description: ''"

 

If I use TList instead of an array, then getting into TestComplete works without errors, but the result of the function is just a pointer to TList, without the ability to access its Items.

 

However, if in Delphi I declare an indexed property that returns a object of custom class, there is no problem getting the object into the testcomplete:

property Items[Index: Integer]: TMyClass read GetItem;


But this is not what I need, I need to get the entire array of objects in one call.
Is it possible to do this?

7 Replies

    • warnerbrothers1's avatar
      warnerbrothers1
      New Contributor

      An array can contain any number of elements.

      Usually more than 100 and less than 1000

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You can get the object, but not the object type. Delphi array is most likely different to JavaScript array.

     

    Do an internet search to see if stackoverflow.com has possible solutions.

  • eykxas's avatar
    eykxas
    Regular Contributor

    Hi,

    If you can get one item of the array, then you could get items one by one and create a new array within TC.

    • warnerbrothers1's avatar
      warnerbrothers1
      New Contributor

      Hi

      This is precisely what I want to avoid. Sequential reading is too slow. Because of this, I want to get an array of objects in one call.