Passing IDispatch from VBScript to VI Server 
Author Message
 Passing IDispatch from VBScript to VI Server

This is a little complicated, but let me try to explain ...

I wish to create an instance of an automation object in VBScript,
and call a VI passing the created object to the VI, then invoke
methods of the object from within the VI.

The automation object is implemented in ATL and is fully functional
and tested. It has one method - testMethod with no parameters.

This is what my VBScript is similar to:

  Option Explicit

  Dim labview
  Set labView = WScript.CreateObject( "LabView.Application.6" )

  Dim viRef
  Set viRef = labView.GetVIReference( "C:\LVActiveX\LVActiveX.vi" )
  viRef.FPWinOpen True

  WScript.Echo viRef.Name

' create the test object and call it's one and only method just to
make sure it works
  Dim testObject
  Set testObject = WScript.CreateObject( "Test.testObject" )
  testObject.testMethod

  Dim inNames(3)
  inNames(0) = "Input1"
  inNames(1) = "Input2"
  inNames(2) = "InputRef"
  inNames(3) = "MyOutput"

  Dim params(3)
  params(0) = 5
  params(1) = 7
' pass the test objects IDispatch in one of the params
  Set params(2) = testObject

  viRef.Call inNames, params

  WScript.Echo params(3)

  WScript.StdIn.ReadLine

  labView.Quit

  Set testObject = Nothing
  Set labView = Nothing

The VI simply takes the 2 numeric inputs, adds together and writes the
output to MyOutput, but also invokes the testMethod on the input
IDispatch reference.

It all works fine except the testMethod is never called from the VI.
Using some debugging I have determined that the input automation
reference
in the VI is receiving a NULL.

Any ideas on this would be greatly appreciated .

cheers



Mon, 27 Sep 2004 11:02:56 GMT  
 Passing IDispatch from VBScript to VI Server
Bumer,

I have tried something similar (using SetControlValue to set the
refnum) and all it did was to crash LabVIEW.
This is not a definite answer but first I doubt that a COM object
refnum is a valid datatype that can be passed in a call. Second, I
also doubt that an object refnum created in one process (wscript.exe)
can be used in another (labview.exe). I think that you have to create,
manipulate, release an object in the process that created it.



Tue, 28 Sep 2004 00:34:54 GMT  
 Passing IDispatch from VBScript to VI Server
That's what I was thinking also, I was hoping that
somehow the interface marshalling would have created
a proxy to the object before it sent it to the
VI.  Thanks for the response

cheers



Wed, 29 Sep 2004 02:29:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using VI Server to pass data between a Labview Executable and a VI

2. Best method to pass high speed graph data from a VI Server called VI

3. How to pass a IDispatch parameter to activex dll

4. How to pass a IDispatch parameter to activex dll

5. Passing COM IDispatch from C to PythonCOM

6. Using control reference with a Sub-vi over a TCP VI Server connection

7. Using control reference with a Sub-vi over a TCP VI Server connection

8. How do I use server to control for sub-vi from a main vi

9. Remote VI won't load when called with VI Server

10. vi server killed his child when the server is ready

11. Can I pass a Control Reference to a VI called with VI server?

12. "Out Port.vi": passing from Windows NT 4.0 to Windows 2000

 

 
Powered by phpBB® Forum Software