SP_AMATCHES

AMATCHES()

  Short:
  ------
  AMATCHES() Counts the matches of an array with condition

  Returns:
  --------
  <nMatches> => Number of matches

  Syntax:
  -------
  AMATCHES(aTarget,[bCondition])

  Description:
  ------------
  <aTarget> is the target array. Normally an array of
  numeric values.

  [bCondition] is an optional codeblock used to select
  a subset of the array. This could be used to filter out 0's or
  non-numeric elements. The block must accept an array element as
  a parameter, and return true or false <expL> to determine if
  this element is part of the desired subset.

  Without [bCondition], the length of the array is
  returned.

  Examples:
  ---------
   v := AMATCHES(aSales)
   v := AMATCHES(aSales,{|e|valtype(e)=="N".and.e<>0})
   v := AMATCHES(aSales,{|e|valtype(e)=="C".and.e=="D"})

  Source:
  -------
  S_ASTATS.PRG

 

SP_AKOUNT

AKOUNT()

  Short:
  ------
  AKOUNT() Counts exact matches of value in array

  Returns:
  --------
  <nMatches>  => Number of matches

  Syntax:
  -------
  AKOUNT(aTarget,expWhatever)

  Description:
  ------------
  Counts # of exact matches of <expWhatever> in
  <aTarget>. <expWhatever> can be of any type.

  Examples:
  ---------

   AFIELDS(aFields,aTypes)
   nChar  := AKOUNT(aTypes,"C")  // count C fields
   nNum   := AKOUNT(aTypes,"N")  // count N fields
   nDate  := AKOUNT(aTypes,"D")  // count D fields

  Notes:
  -------
  See also AMATCHES() which allows a code block.

  Source:
  -------
  S_AKOUNT.PRG