John_Laird wrote:
One more thing...you are familiar with VB.NET...if you can't get JScript to do what you want DIRECTLY you can always write your code to do this in VB.NET, compile it into a DLL, then call the DLL to do what you want from JScript in TestComplete.
Thanks a lot John. You're right, it is a logic problem.
After looking to your last quote, I started to think about that calling a DLL function will be more easier since I will just need to call the function I need.
So I built a DLL with only one simple function that returns True or False in VB.net
I tried, using the "Calling DLL functions for Tests" tutorial, to load and call the function in my DLL but it always fails...
I'm pretty sure that I am doing it the wrong way in the TC script but I am not able to figure what is wrong.
Here's my DLL code:
Imports System.Net
Public Class Class1
Public Function Connect_Relay_Board(IP As String, Port As Integer)
Try
TCPClient1 = New Sockets.TcpClient
TCPClient1.Connect(IP, Port)
Catch ex As Exception
Return False
End Try
Return True
End Function
End Class
And here's my script code:
function Test()
{
var Ipaddress,port,iptest;
var def_DLL, lib, i;
Ipaddress = "192.168.46.12";
port = 3000;
def_DLL = DLL.DefineDLL("Class1");
def_DLL.DefineProc("Connect_Relay_Board",VT_LPSTR,VT_INT,VT_BOOL);
def_DLL.DefineAlias("Connect","Connect_Relay_Board");
lib = DLL.Load("C:\\relayboard.dll","Class1");
i = lib.Connect(Ipaddress ,port);
Log.Message(i)
}
I wanted to make it simple to test it but apparently, it doesn't work..
.
i = lib.Connect(Ipaddress ,port);
This line returns: Object doesn't support this property or method
If you or someone else can, according to the DLL example, give me the right way to load and call DLL function in TC, I will really appreciate.
Thank you very much for your help!
Francis