CTAPI (Citect API) in VB, ¡¡HELP NEEDED!!

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

formatting link
.

/Sven

Reply to
<answerto
Loading thread data ...

I assume you are using CitectSCADA v5.42? I haven't tried to use the VB functionality in Citect but prefer to use Cicode since AFAIK the VB is compiled directly to Cicode anyway - even Citect's own people don't use VB.

Where are you? Have you tried emailing Citect Support ( snipped-for-privacy@citect.com)?? They are usually pretty quick respondinng and will give you the right answers and not just our guesses.

Good luck!

Cameron:-)

Reply to
Cameron Dorrough

--- Clearification: --- You misinterpreted my question. I use Microsoft Visual Basic 6.0 writing an own software. This software needs to communicate with one or more Citect applications. So I use the Citect CTAPI. Yes, I also asked Citect and yes they are answering pretty fast, but I also think that this kind of questions fit well in this group.

--- Cicode: --- Cicode is one of the two script languages in Citect. The other is Cypress VBA.

"Cameron Dorrough" skrev i meddelandet news:bmi2m1$on0$ snipped-for-privacy@merki.connect.com.au...

Reply to
<answerto

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.