count Functions

Prev Next

Function Names

count, count ignore zero, count ignore blanks, count ignore both

Description

These functions counts number of affected parameters. The suffix ... ignore zero excludes all zero values: Numeral 0, Boolean false and blank dates. The suffix ... ignore blanks excludes all strings with blank values: String blank (0 characters), blank dates and empty sets in parameter sets (but includes sets containing something, including nested empty sets).
The suffix ... ignore both covers both of the above.
Please note that equivalent conditional combination functions are also available for the function names listed above which allows you to pre-select specific parameters to include in the calculation using one or more comparisons .

Call as: function

Parameter count

Min 1

Parameters

No.TypeDescription
1, etc.
input
valid types All function parameters:

Same parameter passing principle is applied like other series functions such as add(), sub(), etc.
See Two parameter passing methods for series functions for details..

Return value

TypeDescription
numeral Result

Calculated value

Exceptions

Function names containing 'numeral' assert exceptions if values provided are not of type numeral.

Examples

      echo( count              ( 1, 2, 3, a, '', ' ',0 )  ); // 7
      echo( count ignore zero  ( 1, 2, 3, a, '', ' ',0 )  ); // 6
      echo( count ignore blanks( 1, 2, 3, a, '', ' ',0 )  ); // 5 (only pure blank ignored)
      echo( count ignore both  ( 1, 2, 3, a, '', ' ',0 )  ); // 4 (both 0 and blank ignored)

      echo( count              ( date(today), date(""), true, false )  ); // 4
      echo( count ignore zero  ( date(today), date(""), true, false )  ); // 2 (blank date, false)
      echo( count ignore blanks( date(today), date(""), true, false )  ); // 3 (blank date)
      echo( count ignore both  ( date(today), date(""), true, false )  ); // 2 (both)

Output

7
6
5
4
4
2
3
2
Try it yourself: Open LIB_Function_count.b4p in B4P_Examples.zip. Decompress before use.

See also

counting parameter set elements with {}