Forum Discussion
6 Replies
- AlexKarasCommunity HeroHi
Nassim,
Something like this (untested):
Dim arr
Redim arr(8)
Set arr(0) = obj1
...
Set arr(7) = obj8
...
Log.Message arr(1).urlStr
...
Set objFromArray = arr(7)
Log.Message objFromArray.urlStr - YMinaev
Staff
- nassimOccasional ContributorHi,
Thank you for your reply.
In Project Explorer, I chose ODT->CLASSES and defined a class SDP with properties hh and cuts (I found no way to define the types.)
Afterwards, I wrote these two Subs:
Sub createSPArray()
Dim strSPArray
Redim strSPArray(8)
End Sub
Sub populatestrSPArray(i, h)
j = aqConvert.StrToInt(i)
Set testObj = ODT.Classes.New("SDP")
testObj.hh = h
testObj.cuts = Project.Variables.clientTimeStamp
Set strSPArray(j) = testObj
End Sub
In my keyword test, I call these Subs. However, at the line: Set strSPArray(j) = testObj
I become an exception: Laufzeitfehler in Microsoft VBScript
Typen unverträglich: 'strSPArray'Laufzeitfehler in Microsoft VBScript
Typen unverträglich: 'strSPArray'
Does anyone have an idea?
Thanks - YMinaev
Staff
Hi,
strSPArray doesn't exist inside 'populatestrSPArray'. It is declared in another function, and it is out of scope. - nassimOccasional ContributorHi,
trying to solve the possible scope problem, I defined a variable in my keywordtest as: strSPArray (for the type, I found Object type nearest to an array of objects, although I am not sure at all)
I changed the Sub populatestrSPArray:
Sub populatestrSPArray(i, h)
j = aqConvert.StrToInt(i)
Set testObj = ODT.Classes.New("SDP")
testObj.hh = h
testObj.cuts = Project.Variables.clientTimeStamp
Set strSPArray(j) = testObj
End Sub
I also wanted to add the line Redim KeywordTests.refEnvUsageTestFF.Variables.strSPArray(8) but the syntax is not correct (shown to be red in script by TestComplete)
Now I call just the Sub populatestrSPArray in my test.
An Exception occurs again: (translated:) Run time exception. The types are not compatible: strSPArray
Does anyone have an idea?
Why can a Keywordtest variable not redim(med) in script?
Thanks