cancel
Showing results for 
Search instead for 
Did you mean: 

can i declare array with one element?

elyush
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
elyush
Occasional Contributor

RE: can i declare array with one element?

Heeyy.. 😞 can u help me?



Thanks in advance..
nwang66
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
elyush
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)

nwang66
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

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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors