Hello!
I have a table called “Interlock” with three columns. The data is coming from a tag called “Interlock”. I have it set up so that I can pass in a tag path and the table will show the information in the interlock section of that tag. The first column is called “InterlockedTag” and it is a string value which contains the exact tag path of the value I will be comparing the second column with. The second column is called “DesiredStatus” and is a boolean value. Overall, I am trying to take the string value in column “InterlockedTag” and use it to check the value of that tag. I am then trying to get it to check and see if the value is the same as the value in column “DesiredStatus”. I am trying to set the third column “ColourNum” to 1 if they are the same and 0 if they are not.
I need to do this for every row indiviually so I am trying to use a for loop to loop through all the rows. Unfortunatley, the size of the table will be different depending on the initial tag path that has been passed in. I am using a range of (0 - numOfRows) for the for loop to operate and I do not know how to get the current row that the script is on and the maxiumum number of rows in that instance of the table.
Does anyone know how I can get the current row number (as in the position) and the number of rows that appear? I have posted the code I have written so far.
Thank you!
rowNum = 0 #Index of row that the for loop is on. Need to get this value. 0 is placeholder value.
numOfRow = 4 #Number of total rows (this will vary depending on the tagpath). Need to get this value. 4 is placeholder value.
table = event.source.parent.getComponent('Table')
for rowNum in range (0, numOfRow, 1):
data = event.source.parent.getComponent('Interlock').data
pathToRead = system.tag.read("InterlockedTags").value.geValueAt(rowNum, 0) #String containing the tag path
trueStatusCheck = data.getValueAt(rowNum, 1) #Boolean which shows the desired status
if pathToRead == trueStatusCheck:
colourNum = 1 #ColourNum is the third column and I would like to make it control the colour of the row in the future.
else:
colourNum = 0