Hello,
This is my first time scripting with Ross Xpressions and using Visual Basic. I also do not, in any regard, have a strong background in coding or scripting. I took an Into to Comp Sci class in college, where we learned the basics of Python.
Here is what I would like to do;
We pull live stats into Xpressiosn through our Datalinq server. Within that live XML, a part displays the game's plays with a 1.5-second delay to the real-time play. I want to write a script that reads this XML file and takes graphics live using the TakeID in our sequence. This is the script I have written so far with documentation from Microsoft; however, it does not work. The script compiles; however, it does nothing. To be completely honest I am 100% lost on this process and imagine that this script is not written even remotely correctly. Any help would be greatly appreciated!
Sub ProcessAndTriggerScenes()
' Create a new XPression engine and sequencer instance
Dim Engine As New xpEngine
Dim Sequencer As xpSequencer
Sequencer = Engine.Sequencer ' Remove 'Set'
' Declare other variables
Dim xmlDoc As Object
Dim plays As Object
Dim playNode As Object
Dim vh As String
Dim uni As String
Dim action As String
Dim shotType As String
Dim fastRecall As String
Dim homeAway As String
Dim shotCode As String
Dim takeItem As xpBaseTakeItem
Dim success As Boolean
' Load XML
xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.Load("D:\Live Games\Stats.xml") ' Update with the correct file path
' Check if the XML is valid
If xmlDoc.parseError.errorCode <> 0 Then
MsgBox ("Error loading XML: " & xmlDoc.parseError.reason)
Exit Sub
End If
' Get all play nodes
plays = xmlDoc.SelectNodes("//play")
' Loop through each play node
For Each playNode In plays
' Extract attributes
vh = playNode.getAttribute("vh")
uni = playNode.getAttribute("uni")
action = playNode.getAttribute("action")
shotType = playNode.getAttribute("type")
' Process only "GOOD" actions
If action = "GOOD" Then
' Determine home or away
If vh = "H" Then
homeAway = "1"
ElseIf vh = "V" Then
homeAway = "2"
Else
Continue For
End If
' Determine shot type
If shotType = "3PTR" Or shotType = "3POINTER" Then
shotCode = "3"
Else
shotCode = "2"
End If
' Generate Fast Recall code
fastRecall = homeAway & shotCode & uni
' Access the take item using Fast Recall ID
success = Sequencer.GetTakeItemByID(CInt(fastRecall), takeItem)
If success And Not takeItem Is Nothing Then
' Execute the take item to put it on air
takeItem.Execute
' Wait for 3 seconds
PauseForSeconds (3)
' Take the scene off air by executing it again (toggle off)
takeItem.Execute
End If
End If
Next
End Sub
' Function to pause execution
Sub PauseForSeconds(ByVal seconds As Integer)
Dim endTime As Double
endTime = Timer + seconds
Do While Timer < endTime
' Wait
Loop
End Sub
------------------------------
Jonathan Peters
Team Lead & Broadcast Engineer
Forester Digital Network
------------------------------