Skip to content

Instantly share code, notes, and snippets.

@jpdillingham
Created December 29, 2016 12:42
Show Gist options
  • Save jpdillingham/77f4e3286947eee67be4d4862c0897b4 to your computer and use it in GitHub Desktop.
Save jpdillingham/77f4e3286947eee67be4d4862c0897b4 to your computer and use it in GitHub Desktop.
Dim Tags as TagGroup
Dim TagsInError as StringList
Dim Result as boolean
Dim ReadReasult as Integer
Dim Timeout as Long
' set timeout limit to now + 15 seconds
Timeout = Timer + 15
Set Tags = CreateTagGroup(Me.AreaName)
'******************************************************
' write a value to a tag
'******************************************************
Tags.Add(<TagToWrite>)
Tags.Item(<TagToWrite>).PendingWriteValue = <NewValue>
Result = Tags.WritePendingValues(TagsInError)
if (Result) then
' write succeeded
else
' write failed. do something with TagsInError. or not.
end if
'******************************************************
' read a value from a tag
'******************************************************
Tags.Add(<TagToRead>)
Tags.Item(<TagToRead>).RefreshFromSource
Do While True
ReadResult = Tags.Item(<TagToRead>).Value
if (ReadResult > 0) Then Exit Do
If (Timer > Timeout) Then Exit Do
DoEvents
Loop
If (ReadResult = 1) Then
' read succeeded
Else
' read failed
End if
Set Tags = Nothing
@DemonAlucard
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment