SP_AMVARIANCE

AMVARIANCE()

  Short:
  ------
  AMVARIANCE() Variance on a given element of multi-dim array

  Returns:
  --------
  <nVariance> => average of array element

  Syntax:
  -------
  AMVARIANCE(aMult,nElem,[bCondition])

  Description:
  ------------
  Returns variance of array <aMult> element <nElem>.
  [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 a subarray as a parameter, and
  return  true or false <expL> to determine if this element is
  part of the desired subset. Please note that the codeblock
  accepts the whole subarray, not  just subarray element <nElem>

  Examples:
  ---------

   ?"Total file size here is "
   ??AMSUM(DIRECTORY(),2)

   ?"Total .EXE file size here is "
   ??AMSUM(DIRECTORY(),2,{|e|".EXE"$e[1]}  )

   ?"Variance:"
   ??AMVARIANCE(DIRECTORY(),2,{|e|".EXE"$e[1]}  )

  Notes:
  -------
  Coded by Matthew Maier.

  Presumes all sub-arrays are of equal length

  Source:
  -------
  S_AMSTAT.PRG

 

SP_AMSUM

AMSUM()

  Short:
  ------
  AMSUM() Sum on a given element of multi-dim array

  Returns:
  --------
  <nSum> => sum of array element

  Syntax:
  -------
  AMSUM(aMult,nElem,[bCondition])

  Description:
  ------------
  Returns sum of array <aMult> element <nElem>.

  [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 a subarray as a
  parameter, and return  true or false <expL> to determine if this
  element is part of the desired subset. Please note that the
  codeblock accepts the whole subarray, not  just subarray element
  <nElem>

  Examples:
  ---------

   ?"Total file size here is "
   ??AMSUM(DIRECTORY(),2)

   ?"Total .EXE file size here is "
   ??AMSUM(DIRECTORY(),2,{|e|".EXE"$e[1]}  )

   use customer
   ?"Total field size "
   ??AMSUM(DBSTRUCT(),3)

   use customer
   ?"Total CHARACTER field size "
   ??AMSUM(DBSTRUCT(),3,{|e|e[2]=="C"} )

  Notes:
  -------
  Coded by Matthew Maier.

  Presumes all sub-arrays are of equal length

  Source:
  -------
  S_AMSTAT.PRG

 

SP_AMSTDDEV

AMSTDDEV()

  Short:
  ------
  AMSTDDEV() Standard Deviation on a given element of
  multi-dim array

  Returns:
  --------
  <nVariance> => average of array element

  Syntax:
  -------
  AMSTDDEV(aMult,nElem,[bCondition])

  Description:
  ------------
  Returns Standard Deviation of array <aMult> element
  <nElem>.  [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 a subarray as a parameter, and
  return true or false <expL> to determine if this element is
  part of the desired subset. Please note that the codeblock
  accepts the whole subarray, not  just subarray element <nElem>

  Examples:
  ---------
   ?"Total file size here is "
   ??AMSUM(DIRECTORY(),2)

   ?"Total .EXE file size here is "
   ??AMSUM(DIRECTORY(),2,{|e|".EXE"$e[1]}  )

   ?"Standard Deviation:"
   ??AMSTDDEV(DIRECTORY(),2,{|e|".EXE"$e[1]}  )

  Notes:
  -------
  Coded by Matthew Maier.

  Presumes all sub-arrays are of equal length

  Source:
  -------
  S_AMSTAT.PRG

 

SP_AMSG

AMSG()

  Short:
  ------
  AMSG() Pop up message box for an array of messages

  Returns:
  --------
  Nil

  Syntax:
  -------
  aMsg(aMsgs,[cTitle],[cFooter],[lCenter],[cColor],[nTop,nLeft])

  Description:
  ------------
  Pops up a box to display messages in <aMsgs>. Each
  element of <aMsgs> can be of type Character, Numeric, Date or
  Logical.

  The box is centered in the middle of the screen by
  default.

  [cTitle]  is an optional title string displayed at
  <nTop>,<nLeft+1>

  [cFooter] is an optional footer string displayed at
  <nBottom>, <nLeft+1>. Default footer is "Press a key.."

  [lCenter]  determines center messages in box or not.
  by default, message lines are left justified. Passing True
  causes messages to be centered.

  [cColor] is the color of the popup box. By default,
  is sls_popcol()

  [nTop,nLeft] are optional TOP/LEFT dimensions for the
  box. Default is centered on the screen, and big enough to hold
  all of the message lines.

  Examples:
  ---------

  aArray := {"Attention:","all items are on sale for",1.99,;
     "today only",date()}

  amsg(aArray,"Sale",nil,.t.)

  Notes:
  -------
  If there are more message lines than will fit in the
  box, up/down arrows will scroll the messages.

  See MSG()

  Source:
  -------
  S_AMSG.PRG

 

SP_AMAVERAGE

AMAVERAGE()

  Short:
  ------
  AMAVERAGE() Average on a given element of multi-dim array

  Returns:
  --------
  <nAverage> => average of array element

  Syntax:
  -------
  AMAVERAGE(aMult,nElem,[bCondition])

  Description:
  ------------
  Returns average of array <aMult> element <nElem>.

  [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 a subarray as a
  parameter, and return  true or false <expL> to determine if this
  element is part of the desired  subset.

  Please not that the codeblock accepts the whole
  subarray, not  just subarray element <nElem>

  Examples:
  ---------

   ?"Average file size here is "
   ??amaverage(DIRECTORY(),2)

   ?"Average .EXE file size here is "
   ??amaverage(DIRECTORY(),2,{|e|".EXE"$e[1]}  )

   use customer
   ?"Average field size "
   ??amaverage(DBSTRUCT(),3)

  Notes:
  -------
  Presumes all sub-arrays are of equal length

  Coded by Matthew Maier.

  Source:
  -------
  S_AMSTAT.PRG

 

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_ALLBUT

ALLBUT()

  Short:
  ------
  ALLBUT() Returns all but last x characters

  Returns:
  --------
  <cAllBut> => All but last n characters

  Syntax:
  -------
  ALLBUT(cInString,nAllBut)

  Description:
  ------------
  Returns all but the rightmost <nAllbutt> letters of
  <cInString>

  Examples:
  ---------

   string := "SUPERFUNCTION"
   string := ALLBUT(string,8)    //  => returns  "SUPER"

  Notes:
  -------
  Useful when you don't know the length of a string in
  order to take left(x) characters.

  Source:
  -------
  S_ALLBUT.PRG

 

SP_ALENG

ALENG()

  Short:
  ------
  ALENG() Actual length of an array, less trailing nil elements

  Returns:
  --------
  <aLength>  => Actual array length, less trailing NILs

  Syntax:
  -------
  ALENG(aTarget)

  Description:
  ------------
  Determines the actual length of <aTarget>, less
  trailing nils.

  Examples:
  ---------

   a := {1,2,3,4,5,nil,nil,nil}
   ?len(a)       // => returns 8
   ?aleng(a)     // => returns 5

  Notes:
  ------
  This was a C function in prior Super.Libs

  Source:
  -------
  S_ALENG.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

 

SP_AFTYPESX

AFTYPESX()

  Short:
  ------
  AFTYPESX() Returns an array of field types for current dbf

  Returns:
  --------
  <aFields> => an array of field types for the current
  dbf

  Syntax:
  -------
  AFTYPESX()

  Description:
  ------------
  AFTYPESX() creates and returns an array of field types
  from the current dbf. Unlike AFIELDS(), it does not
  require an initialized array beforehand.

  Examples:
  ---------
   aArray := AFIELDSX()
   aTypes := AFTYPESX()

   if (nSelect := mchoice(aArray,10,10,20,20,"Pick Field")) >  0

      ?"Field "+aArray[nSelect]+" was selected"
      ?" of type     "+aTypes[nSelect]

   endif

  Source:
  -------
  S_AFTYPE.PRG