Power Table Configuration Cell Script Help(Solved)

Using a Power Table. I am trying to compare the value to the row below. If the values are different I want the text to be ‘red’ and if the values are the same ‘white’. This is my code that I am using. It works up to the point where the rows end(last row). How do find and escape out of the routine if it is the last row in the table; this would stop errors with ArrayIndexOutOfBoundsException.

This is the code in the def configureCell function:

	if selected:
			return {'foreground' : 'red','background': self.selectionBackground}	
	elif rowView % 2 == 0:
		if value != self.data.getValueAt(rowIndex + 1,colIndex):
			return {'background': 'black','foreground' : 'red'}	
		else:
			return {'background': 'black','foreground' : 'white'}
	else:
		if value != self.data.getValueAt(rowIndex + 1,colIndex):
			return {'background': 'blue','foreground' : 'red'}
		else:
			return {'background': 'blue','foreground' : 'white'}

Can you please explain better the issue?
You mentioned “It works up to the point where the rows end”, are you using a while loop or a for loop?
If you just want to know how many rows your table have, use the command len()

print len(table) will print out the table’s lenght

i didn’t not think you could use len(table) in a Power Table. Could I use self.table?

I just tried to populate a Power Table with a DataSet took from a query and then use the len() function.

query = "SELECT Data_Var_1,Data_Var_2,Data_Var_3 FROM Table"
QueryTable = system.db.runQuery(query,'DBname')
event.source.data = QueryTable
last_row = len(QueryTable) 

I don’t think you can put this in the configureCell Extension functions script area…I will add that to my issue above

this works now…

	if rowIndex < self.data.rowCount -1:
		if selected:
			return {'foreground' : 'red','background': self.selectionBackground}	
		elif rowView % 2 == 0:
			if value != self.data.getValueAt(rowIndex + 1,colIndex):
				return {'background': 'black','foreground' : 'red'}	
			else:
				return {'background': 'black','foreground' : 'white'}
		else:
			if value != self.data.getValueAt(rowIndex + 1,colIndex):
				return {'background': 'blue','foreground' : 'red'}
			else:
				return {'background': 'blue','foreground' : 'white'}