[英]pass arguments to function from one unit to another in testcomplete and how to call it
i am facing a vb script run time error saying "wrong number of arguments or invalid property assignment". 我正面临一个vb脚本运行时错误,说“错误的参数数量或无效的属性赋值”。 '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. 在USEUNIT之后,您需要指定将在此单元中使用其功能的单元的名称。 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 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 我从官方论坛发现这个执行“调用UnitName.SubWithParams(1,”“string”“,True)”'使用带有Call关键字和括号的语法
Execute "UnitName.SubWithParams 1, ""string"", True" ' Syntax without the Call keyword and parentheses 执行“UnitName.SubWithParams 1”,“string”“,True”'没有Call关键字和括号的语法
res = Eval("UnitName.FunctionWithParams(1, ""string"", True)") res = Eval(“UnitName.FunctionWithParams(1,”“string”“,True)”)
' Inserting parameter values dynamically '动态插入参数值
strFunctionCall = aqString.Format("UnitName.FunctionWithParams(%d, ""%s"", %s)", 42, "string", CStr(True)) strFunctionCall = aqString.Format(“UnitName.FunctionWithParams(%d,”“%s”“,%s)”,42,“string”,CStr(True))
res = Eval(strFunctionCall) res = Eval(strFunctionCall)
but still donot know how exactly should we pass the parameters 但仍然不知道我们应该如何传递参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.