ALBERTO_SERRANO
11 years agoNew Contributor
Call script (VBScript) with ByRef args from KeywordTest
Hi
I'm trying to call a function (VBScript) from a KeyWordTest passing two arguments ByRef
In the call I pass two local variables LibRef and TpmCount to DllFunction2. The execution finishes Ok, the LastResult is true, but TpmCount (local KeywordTest variable) is not updated when the function call is finished
Am I missing something??
Many thanks in advance
Kindest regards, Alberto
I'm trying to call a function (VBScript) from a KeyWordTest passing two arguments ByRef
In the call I pass two local variables LibRef and TpmCount to DllFunction2. The execution finishes Ok, the LastResult is true, but TpmCount (local KeywordTest variable) is not updated when the function call is finished
Am I missing something??
Many thanks in advance
Kindest regards, Alberto
- Hi Alberto,
ByRef doesn't work with project, project suite and keyword test variables. You need to access the variable directly to change its value:
Function DllFunction2(Lib, CntVariableName)
...
If Result Then
KeywordTests.Test1.Variables.VariableByName(CntVariableName) = Count
End If
...
End Function
and call the function like this:Run Script Routine DLLFunction2 Variables.LibRef, "TpmCount"
You can use project variables instead of keyword test variables to avoid hard-coding the keyword test name inside the script function.