pass arguments to function from one unit to another in testcomplete and how to call it

StackOverflow https://stackoverflow.com/questions/22811332

  •  26-06-2023
  •  | 
  •  

質問

i am facing a vb script run time error saying "wrong number of arguments or invalid property assignment". 'useunit sub in unita call unita.testsub(param1,param2) end sub

'sub in unitb sub testsub(param1,param2) ..... end sub

役に立ちましたか?

解決

After USEUNIT you need to specify the name of the unit whose functions you will use in this unit. So, change your code in the following way:

unita

'USEUNIT unitb
sub main
  dim param1
  dim param2
  param1="Test"
  param2="Complete"
  call unitb.testsub(param1,param2)
end sub

unitb

sub testsub(param1,param2)
  Log.Message(param1 & param2)
end sub

他のヒント

I believe that

call unita.testsub(param1,param2)

should be

call unitb.testsub(param1,param2)

i found this from the oficial forums Execute "Call UnitName.SubWithParams(1, ""string"", True)" ' Using syntax with the Call keyword and parentheses

Execute "UnitName.SubWithParams 1, ""string"", True" ' Syntax without the Call keyword and parentheses

res = Eval("UnitName.FunctionWithParams(1, ""string"", True)")

' Inserting parameter values dynamically

strFunctionCall = aqString.Format("UnitName.FunctionWithParams(%d, ""%s"", %s)", 42, "string", CStr(True))

res = Eval(strFunctionCall)

but still donot know how exactly should we pass the parameters

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top