Counting occurrences of a value in a table

Tips and Techniques

Moderators: ZeenyxSupport, blesuer

Post Reply
GordonWeil
Posts: 2
Joined: Wed Jun 25, 2014 1:41 pm

Counting occurrences of a value in a table

Post 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())
Post Reply