cancel
Showing results for 
Search instead for 
Did you mean: 

can i declare array with one element?

Highlighted
Occasional Contributor

can i declare array with one element?

Hi !

I have declared array, and now i want to add one item in array, and when i execute, i get en error!

 can't i declare array with  1 length,? i mean can't i have array with one element?



For example



MyStruct = DLL.DefineType("TemplateCodesStruct", VT_VARIANT, "Value")

Set TemplateCode = DLL.New("TemplateCodesStruct",1)

TemplateCode.Item(0).Value = "AEdit"





And the error was "Objecy doesn't support this property or method TemplateCode.Item:"






5 REPLIES 5
Highlighted
Occasional Contributor

RE: can i declare array with one element?

Heeyy.. 😞 can u help me?



Thanks in advance..
Highlighted
Contributor

RE: can i declare array with one element?

Count The number of the elements to be created. By default, it is 1, which means that you are creating one instance of the specified type. If Count is greater than 1, it means that you are creating an array of elements of the specified type.  -- copied from TestComplete help


    Try this, 



    ...

   MyStruct = DLL.DefineType("TemplateCodesStruct", VT_VARIANT, "Value")

   Set TemplateCode = DLL.New("TemplateCodesStruct",2)

   TemplateCode.Item(0).Value = "AEdit"

    

    I think the count should be 2, which means array ... hope this hels.



Nancy
Highlighted
Occasional Contributor

RE: can i declare array with one element?

sooo, can't i have an array with one element?? i always must have min 2 elements in array....?



MyStruct = DLL.DefineType("TemplateCodesStruct", VT_VARIANT, "Value")

   Set TemplateCode = DLL.New("TemplateCodesStruct",1)

Highlighted
Contributor

RE: can i declare array with one element?

It sounds Yes. Well if your array only has one item, why do you need an array? Or you can create an 2 items array, but only put one item in, leave item(1) as null, TestComplete will still pass the test...



Nancy
Highlighted

RE: can i declare array with one element?


Hi Elya,





As far as we understand, an array consisting of one object of a specific type and an object of this type do not differ, and your code should work fine with a single object even if it is expecting an array. If this is not your case, could you please post here the signature or declaration of the function you are working with so we can recreate this situation here?
--
Dmitry Nikolaev

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!

Retrieve Data from a Web Page

Participate!
Top Kudoed Authors