Sticky Binding Values (my attempt to recreate Alarm Status marquee functionality)

Hi All,
I am trying to do a label binding to recreate the functionality of the marquee mode of the vision alarm status in Perspective 8.1.25

My issue is that what is being displayed is inconsistent with the Dataset (i.e. the code will pass in one as the index but the label will show the value for 0). In many cases values are skipped over. Is there anything that I am failing to take into account that I can mitigate through python?
python transform is attached to a query binding that just runs the query GETDATE() every 5 seconds and the code for the transform is attached below

def transform(self, value, quality, timestamp):
	from time import sleep
	results = system.alarm.queryStatus(state="2",priority="3",includeShelved=False)
	resultDS = results.getDataset()
	curAlert = self.custom.curAlert
	self.custom.totalAlerts = resultDS.getRowCount()
	sleep(0.3)
	if self.custom.totalAlerts ==0:
		self.custom.curAlert = 0
		return "No current active alarms"
	self.props.style.backgroundColor ="#FFFFFF"
	self.props.textStyle.color ="#000000"
	
	
	if curAlert < self.custom.totalAlerts-1:
		
		self.custom.curAlert +=1
	else:
		self.custom.curAlert = 0
	sleep(0.3)
	outString = resultDS.getValueAt(self.custom.curAlert,2)
	self.props.style.backgroundColor ="#000000"
	self.props.textStyle.color ="#FFFFFF"
	
	if self.custom.curAlert %2 == 1:
		sleep(3)
	return str(outString)

Thanks for your help in advance.

Hello Chris,

I tested a bit with your code and found that this may have been setting my custom parameter 'totalAlerts' to zero and then operating the, "No current active alarms" return statement. Are you certain that your alarm query is returning a dataset with rows?

resultDS = results.getDataset()
self.custom.totalAlerts = resultDS.getRowCount()

Hi Aaron,
Thanks for your response. I am certain am getting data set with rows. Empty datasets haven't been an issue in the slightest. My issues has been tying the cycling of the alarms to query polling which causes an inconsistent amount of time for each alarm that has been displayed. I have been doing multiple revisions so a great deal of the code has changed but not those lines of code. I am still having issues but I feel it is unlikely that the cause is based on setting a value to the row count
Thanks,
-Chris