I try to use Citect CTAPI in Microsoft VB6 SP3 but fail. A few functions work, like ctOpen, ctClose and ctTagWrite.
Private Declare Function ctOpen Lib "ctapi" (ByVal sServer As String, ByVal sUser As String, ByVal sPassword As String, ByVal lType As Long) As Long Private Declare Function ctClose Lib "ctapi" (ByVal lCtHandle as Long) As Boolean Private Declare Function ctTagWrite Lib "ctapi" (ByVal lCtHandle As Long, ByVal sTag As String, ByVal sValue As String) As Boolean
I think I need to use the functions ctTagRead, ctStrToPoint, ctTagToPoint, ctPointRead, ctPointClose, ctPointToStr, ctPointWrite, ctRawToEng and ctCicode, but am focusing on ctTagRead to start with:
The c declaration for ctTagRead is: BOOL ctTagRead(hCTAPI, sTag, sValue, dwLength)
One c example from the Citect help is: ctTagRead(hCTAPI, "PV123", sProcessValue, sizeof(sProcessValue));
I have tried several alternatives, but this is my current code part: Private Declare Function ctTagRead Lib "ctapi" (ByVal lCtHandle As Long, ByVal sTag As String, ByRef sValue As String, ByVal lLength As Long) As Boolean Dim sValue As String * 80 ctTagRead lCtHandle, "MyCitectTag", sValue, Len(sValue)
This makes CTAPI crash. sValue must be declared as ByRef to make possible for CTAPI to return the value there. I use fixed length string because of experience from other c dll's in VB.
I need correct VB declarations for ctTagRead and the other remaining functions and/or some sample VB code. Or any suggestions!! If anyone used CTAPI in VB, please e-mail me (just remove NOSPAM from my e-mail address) or post an answer here!
If you need the Citect software, it's available for free at
/Sven