Page 1 of 1

Counting occurrences of a value in a table

Posted: Wed Jan 07, 2015 6:52 pm
by GordonWeil
The arguments are the name of the column in the row and the string value to match. I work in PowerBuilder but the code will probably work extending other table classes.

Usage:

Integer iCount = MainWindow.MainTable.GetNumberOfMatches("Columnname","SomeValue")

Zee code:

[-] extend class PbTable
[-] Integer GetNumberOfMatches (String sColumnName, String sValue )
[ ] List <String> ls
[-] for (AppObject ao in this.$("Row")[all])
[-] if ( ao.$(sColumnName).GetText( ) == sValue )
[ ] ls.Add(ao.$(sColumnName).GetText())
[ ] return (ls.Count())