KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Counting items of a certain value in an array
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: January 5, 2005

In previous versions of 4D, if you wanted to count the number of a certain value in an array, you would probably have to write a loop to do it.

A new feature in 2004 allows you to do this with one command, Count in array.

For example, suppose you were using listboxes in 2004. A listbox is an array of boolean values that tell you whether an item is currently selected in that listbox. To count the number of selected values, you might write something like this:

  $selected:=Count in array(MyListbox;True)

The variable $selected would then be equal to the number of selected items in MyListbox.