Sign in to follow this  
Followers 0
CrashOverRideZX

Some Datatype Or Byref Problem I Think

4 posts in this topic

K so I am making COM calls to an automation dll.

The call requests for two arrays to be passed ByRef Values As Variant and Errors as Long

When ever I make the call I am told there is a TypeMismatch but I know that all but these two variables are the problem.

Here is a example in VBA

Note the Matrikon.OPC.HDAAutomation com object is referenced in Access

Option Base 1

Option Explicit

Sub WriteOne()

Dim HDAServer As OPCHDAServer

Dim HDAItem As OPCHDAItems

Dim Value

Dim Test

Dim Style

Dim Title

Dim tstValue

Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.

Title = "MsgBox Demonstration" ' Define title.

'Connect to OPC sim server

Set HDAServer = New OPCHDAServer

HDAServer.Connect "Matrikon.OPC.DesktopHistorian"

'Add one item

Set HDAItem = HDAServer.OPCHDAItems

HDAItem.AddItem "Random.Int4", 1 'Client Handle is 1

Dim ItemHandle(1) As Long

Dim ReturnValues() As Variant

Dim Errors() As Long

'only one item

ItemHandle(1) = HDAItem(1).ServerHandle

HDAItem.SyncReadRaw "NOW-50D", "NOW", 0, True, 1, ItemHandle, ReturnValues, Errors

For Each Value In ReturnValues

For Each tstValue In Value

Test = MsgBox(tstValue, Style, Title)

Next tstValue

Next Value

End Sub

The HDAItem.SyncReadRaw call works fine here

When I attempt the same with AutoIT I get the COM Error

Share this post


Link to post
Share on other sites



@CrashOverRideZX

Your are not using a COM error handler to figure out where the error ocurs.

Look in my signature for Example "MS Log Parser" code.

In there you will find an Com Error handler example. This will bring you a little further, to point out what is wrong. :)

Share this post


Link to post
Share on other sites

You were looking at the VBA code.....

My AutoIT script does have a COM Error handler

It always reports that there is a Type Mismatch

Now after looking deeper it is looking for three things were there may be a problem

ServerHandles Array of Longs

ByRef Values Array of OPCHDAHistory objects containg OPCHDAEntry objects

ByRef Errors Array of Longs

So the type mismatch is here somewhere and I am not sure if we can explictly set datatypes in AutoIT

I have also tried this out with Perl and have been able to make this work when setting datatype

I also was wondering if with all the complications of using this dll/COM Object if it would be easier to write

this script using DllCall?

Share this post


Link to post
Share on other sites

So the type mismatch is here somewhere and I am not sure if we can explictly set datatypes in AutoIT

I not quit sure but there are no data types in AutoIT.

Best is to look in the Help file (search for DIM) or to open a new question in this support section,

asking explicitely how to set the datatypes.

Dllcall has more options, but is more complicated to find your way through.

Regards

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0