Ask a Question

Casting From Generic Object

mattc_1
Occasional Contributor

Casting From Generic Object

This is probably more of a VBScript question. I know that it is a limited in functionality but I haven't been able to figure out how to cast out of a Generic Object.



I am using VS2008 to handle all the testing and am running the RunRoutineEx function for my parms. I am passing in an ArrayList that has two String Arrays in them. They pass in fine and I can see the values of each String inside the String Array in the Immediate Window but I thought I would be able to just call parm(0) to get the index 0 value but that does not work because it classified as an object when it gets into the TC Scripts. What's a little different is if I call IsArray it returns true and if I call TypeName it says that it is a String() which makes sense but why can't I use it as such?



Hopefully this all makes sense. 



3 REPLIES 3

RE: Casting From Generic Object


Hi Matthew,





You should be able to do this in the following way:

    ...

    Dim props(1) As Object

    props(0) = "Property1"

    props(1) = "Property2"





    Dim vals(1) As Object

    vals(0) = "Value1"

    vals(1) = "Value2"





    Dim params(1) As Object

    params(0) = props

    params(1) = vals





    Call IntegrationObject.RunRoutineEx("MyProject", "MyUnit", "TestArrParam", params)

    ...


Sub TestArrParam(properties, values)

  For i = 0 To UBound(properties)

    Log.Message properties(i) & " = " & values(i)  

  Next 

End Sub

mattc_1
Occasional Contributor

RE: Casting From Generic Object

That worked. So the problem was that I could pass in a generic object but not a string array.



Thanks.

RE: Casting From Generic Object


Hi Matthew,





A generic object is converted to a value of the Variant type when passed to a test script via TestComplete's COM object.
cancel
Showing results for 
Search instead for 
Did you mean: