'------------------------------------------------------------------------------
' This VB6 subroutine writes a string value to a ControlLogix tag of type string
'
' Parameters
' t is the ControlLogix tag name
' s is the string value to write
'------------------------------------------------------------------------------
Sub WriteLogixString(t As String, s As String)
Asabtcp1.Function = FUNC_AB_LOGIX_WRITE_ELEMENT
' Write string length
Asabtcp1.Memstart = t & ".LEN"
Asabtcp1.SetDataLongM 0, Len(s)
Asabtcp1.MemQty = 1
Asabtcp1.MemType = "D"
Asabtcp1.SyncRefresh
If Asabtcp1.Result <> 0 Then
MsgBox "Error " & Hex(Asabtcp1.Result) & " writing string
length. " & Asabtcp1.ResultString
Exit Sub
End If
' Write string data
Asabtcp1.Memstart = t & ".DATA"
Asabtcp1.MemType = "S"
Asabtcp1.MemQty = Len(s)
Asabtcp1.SyncRefresh
For i = 0 To Len(s) - 1
Asabtcp1.SetDataByteM i, AscB(Mid(s, i + 1, 1))
Debug.Print
Next
Asabtcp1.SyncRefresh
If Asabtcp1.Result <> 0 Then
MsgBox "Error " & Hex(Asabtcp1.Result) & " writing string
data. " & Asabtcp1.ResultString
Exit Sub
End If
End Sub