Code: Select all
;xinclude comateplus.pbi; Varianthelper_include.pb
Procedure LE()
Protected s.s=comate_getlasterrordescription()
If s<>"Okay."
Debug s
EndIf
EndProcedure
*sa.SAFEARRAY=saCreateSafeArray(#TString,1,2)
SA_BSTR(*sa,1)=@"Applications.Application_1.CraneControl.i_WindSpeed.Value"
SA_BSTR(*sa,2)=@"Applications.Application_1.CraneControl.i_ElhouseTempAnalogInput.Value"
*sb.SAFEARRAY=saCreateSafeArray(#TLong,1,2)
SA_LONG(*sb,1)=1
SA_LONG(*sb,2)=2
*sc.SAFEARRAY=saCreateSafeArray(#TLong,1,2)
*sd.SAFEARRAY=saCreateSafeArray(#TLong,1,2)
V_ARRAY_STR(ItemAr.variant)=*sa
V_ARRAY_LONG(CHandleAr.variant)=*sb
V_ARRAY_LONG(SHandleAr.variant)=*sc
V_ARRAY_LONG(ErrorAr.variant)=*sd
opc.comateobject=comate_createobject("opc.automation.1")
opc\invoke("connect('abb.ac800mc_opcdaserver.3')")
gp.comateobject=opc\getobjectproperty("opcgroups\add")
items.comateobject=gp\getobjectproperty("opcitems")
items\invoke("additems(2,"+Str(ItemAr)+" as variant ,"+Str(CHandleAr)+" as variant ,"+
Str(SHandleAr)+" as variant byref,"+Str(ErrorAr)+" as variant byref,#opt,#opt)")
le()
ServerHandles() As Long, ByRef Errors() As Long, Optional RequestedDataTypes As Variant,
Optional AccessPaths As Variant)
and the same VB code runs well:
Code: Select all
Option Explicit
Dim opc As New OPCServer, gp As OPCGroup, items As OPCItems
Dim ItemAr(1 To 2) As String, CHandleAr(1 To 2) As Long, SHandleAr() As Long, ErrorAr() As Long
Dim a&, b&, va, vb, vc, vd
Private Sub Form_Load()
opc.Connect "abb.ac800mc_opcdaserver.3"
Set gp = opc.OPCGroups.Add
Set items = gp.OPCItems
ItemAr(1) = "Applications.Application_1.CraneControl.i_WindSpeed.Value"
ItemAr(2) = "Applications.Application_1.CraneControl.i_ElhouseTempAnalogInput.Value"
CHandleAr(1) = 1
CHandleAr(2) = 2
items.AddItems 2, ItemAr, CHandleAr, SHandleAr, ErrorAr
End Sub