FT Array Functions

 FT_AADDITION()   Add elements unique of source array to target array
 FT_AAVG()        Average numeric values in an array
 FT_ADESSORT()    Sort an array in descending order
 FT_AEMAXLEN()    Find longest element within an array
 FT_AEMINLEN()    Find shortest element within an array
 FT_AMEDIAN()     Find middle value in array, or average of two middle values
 FT_ANOMATCHES()  Find the number of array elements meeting a condition
 FT_AREDIT()      2 dimensional array editing function using TBrowse
 FT_ASUM()        Sum the elements of an array
 FT_RESTARR()     Restore a Clipper array from a disc file
 FT_SAVEARR()     Save Clipper array to a disc file.

 

FT_SAVEARR

 FT_SAVEARR()
 Save Clipper array to a disc file.

 Syntax

      FT_SAVEARR( <aArray>, <cFileName>, <nErrorCode> ) -> lRet

 Arguments

     <aArray> is any Clipper array except those containing
     compiled code blocks.

     <cFileName> is a DOS file name.

     <nErrorCode> will return any DOS file error.

     All arguments are required.

 Returns

     .F. if there was a DOS file error or the array contained
     code blocks, otherwise returns .T.

 Description

     FT_SAVEARR() saves any Clipper array, except those
     containing compiled code blocks, to a disc file.  The
     array can be restored from the disc file using
     FT_RESTARR().

     [10/1/92 Librarian note:

     This function does not appear to work with multi-dimensional
     arrays.  If you'd care to modify it to support this feature,
     please do and send it to Glenn Scott 71620,1521.]

 Examples

    aArray := { {'Invoice 1',CTOD('04/15/91'),1234.32,.T.},;
                {'Invoice 2',DATE(),234.98,.F.},;
                {'Invoice 3',DATE() + 1,0,.T.}  }
    nErrorCode := 0
    FT_SAVEARR(aArray,'INVOICE.DAT',@nErrorCode)
    IF nErrorCode = 0
      aSave := FT_RESTARR('INVOICE.DAT',@nErrorCode)
      IF nErrorCode # 0
         ? 'Error restoring array'
      ENDIF
    ELSE
      ? 'Error writing array'
    ENDIF

 Source: SAVEARR.PRG

 Author: David Barrett

See Also: FT_RESTARR()


FT_RESTARR

FT_RESTARR()
 Restore a Clipper array from a disc file

 Syntax

      FT_RESTARR( <cFileName>, <nErrorCode> ) -> aArray

 Arguments

     <cFileName> is a DOS file name.

     <nErrorCode> will return any DOS file error.

     All arguments are required.

 Returns

     Return an array variable.

 Description

     FT_RESTARR() restores an array which was saved to
     a disc file using FT_SAVEARR().

     [10/1/92 Librarian note:

     This function does not appear to work with multi-dimensional
     arrays.  If you'd care to modify it to support this feature,
     please do and send it to Glenn Scott 71620,1521.]

 Examples

    aArray := { {'Invoice 1',CTOD('04/15/91'),1234.32,.T.},;
                {'Invoice 2',DATE(),234.98,.F.},;
                {'Invoice 3',DATE() + 1,0,.T.}  }
    nErrorCode := 0
    FT_SAVEARR(aArray,'INVOICE.DAT',@nErrorCode)
    IF nErrorCode = 0
      aSave := FT_RESTARR('INVOICE.DAT',@nErrorCode)
      IF nErrorCode # 0
         ? 'Error restoring array'
      ENDIF
    ELSE
      ? 'Error writing array'
    ENDIF

 Source: SAVEARR.PRG

 Author: David Barrett

See Also: FT_SAVEARR()


			

FT_ASUM

FT_ASUM()
 Sum the elements of an array

 Syntax

      FT_ASUM( <aArray> [, <nStartIndex> [, <nEndIndex> ] ] ) -> nSum

 Arguments

     <aArray> is the array containing the elements to be summed.

     <nStartIndex> is the first array item to include,
     defaults to first element.

     <nEndIndex> is the last array element to include,
     defaults to all elements.

 Returns

     The sum of the elements of the array or the lengths of the elements.

 Description

     This function is to sum the elements of a numeric array or to sum the
     lengths of a character array.

 Examples

     FT_ASUM(aSubTotals)               // Sum the Entire Array

     FT_ASUM(aSubTotals, 5)            // Sum from the 5th Element On

     FT_ASUM(aSubTotals, , 10)         // Sum the 1st 10 Elements

     FT_ASUM(aSubTotals, 5, 10)        // Sum Elements 5-10

 Source: ASUM.PRG

 Author: David Husnian


 

FT_AREDIT

FT_AREDIT()
 2 dimensional array editing function using TBrowse

 Syntax

      FT_AREDIT( <nTop>, <nLeft>, <nBottom>, <nRight>, <Array Name>, ;
         <nElem>, <aHeadings>, <aBlocks> [, <bGetFunc> ] ) -> xElement

 Arguments

     <nTop>, <nLeft>, <nBottom>, <nRight> are coordinates for TBrowse

     <Array Name> is name of 2 dimensional to array edit

     <nElem>      is pointer for element in array

     <aHeadings>  is array of column headings

     <aBlocks>    is array of blocks describing each array element

     [ <bGetFunc> ] is get editing function for handling individual elements

 Returns

     Value of element positioned on when exit FT_AREDIT()
     The type of this value depends on what is displayed.

 Description

     This function allows you to position yourself in an array,
     add and delete rows with the <F7> and <F8> keys,
     and pass a UDF with information to edit the individual gets.

 Examples

      FT_AREDIT(3, 5, 18, 75, ar, @nElem, aHeadings, aBlocks)

      This example will allow you to browse a 2 dimensional array
      But you can't edit it since there is no GetBlock UDF
      It allows the user to hit ENTER to select an element or ESC to
      return 0

      * This second example shows how to edit a 2 dimensional array
      * as might be done to edit an invoice

            LOCAL i, ar[3, 26], aBlocks[3], aHeadings[3]
            LOCAL nElem := 1, bGetFunc

      * Set up two dimensional array "ar"

            FOR i = 1 TO 26
               ar[1, i] := i          //  1  ->  26  Numeric
               ar[2, i] := CHR(i+64)  // "A" -> "Z"  Character
               ar[3, i] := CHR(91-i)  // "Z" -> "A"  Character
             NEXT i

      * SET UP aHeadings Array for column headings

            aHeadings  := { "Numbers", "Letters", "Reverse" }

      * Need to set up individual array blocks for each TBrowse column

        aBlocks[1] := {|| STR(ar[1, nElem], 2) } // prevent default 10 spaces
        aBlocks[2] := {|| ar[2, nElem] }
        aBlocks[3] := {|| ar[3, nElem] }

      * set up TestGet() as the passed Get Function so FT_ArEdit knows how
      * to edit the individual gets.

        bGetFunc   := { | b, ar, nDim, nElem | TestGet(b, ar, nDim, nElem) }
        SetColor( "N/W, W/N, , , W/N" )
        CLEAR SCREEN
        FT_AREDIT(3, 5, 18, 75, ar, @nElem, aHeadings, aBlocks, bGetFunc)

 Source: AREDIT.PRG

 Author: James J. Orlowski, M.D.

 

FT_ANOMATCHES

FT_ANOMATCHES()
 Find the number of array elements meeting a condition

 Syntax

      FT_ANOMATCHES( <aArray>, <bCompareBlock> ;
                     [, <nStartIndex> [, <nEndIndex> ] ] ) -> nNoOfMatches

 Arguments

     <aArray> is the array to be searched

     <bCompareBlock> is a code block containing the expression for
     the array elements to be tested with.  Each element is passed
     as a parameter to the block.  If the block returns .T., the
     number of matches will be incremented by one.

     <nStartIndex> is the first array item to include in the search,
     defaults to first element.

     <nEndIndex> is the last array element to include in the search,
     defaults to all elements.

 Returns

     The number of elements that cause the code block to return .T.

 Description

     This function returns the number of array elements that, when passed
     to the supplied code block, cause that code block to return a .T. value.

 Examples

     // Search the Entire Array
     FT_ANOMATCHES(aTries, { | x | x <= 100 } )

     // Search from the 5th Element On
     FT_ANOMATCHES(aCodes, { | x | UPPER(x) == cCurrentCode }, 5)

     // Search the 1st 10 Elements
     FT_ANOMATCHES(aDates, { | x | IS_BETWEEN(DATE()-7,x,DATE() + 7) }, 10)

     // Search Elements 5-10
     FT_ANOMATCHES(aNames, { | x | x <= cLastGoodName }, 5, 10)

 Source: ANOMATCH.PRG

 Author: David Husnian

FT_AMEDIAN

 FT_AMEDIAN()
 Find middle value in array, or average of two middle values

 Syntax

      FT_AMEDIAN( <aArray> [, <nStart> [, <nEnd> ] ] )
                 -> nMedian

 Arguments

     <aArray> is the array containing the elements to be averaged.

     <nStart> is the first array element to include,
     defaults to first element.

     <nEnd> is the last array element to include,
     defaults to last element.

 Returns

     The median average of the array elements

 Description

     This function sorts the elements of a numeric array and
     then returns the value in the middle element of the sorted
     array.  If there is no exact middle value, then it returns
     the average of the two middle values.  Half of the elements
     are > median and half are < median.  A median average may
     more reflect a more useful average when there are extreme
     values in the set.

 Examples

     FT_AMEDIAN( aArray )      // Return Median for entire array

     FT_AMEDIAN( aArray, 2)    // Return Median for elements from 2 to end

     FT_AMEDIAN( aArray, ,9)   // Return Median for 1st 9 elements

     FT_AMEDIAN( aArray,8,40 ) // Return Median for elements 8 to 40

 Source: AMEDIAN.PRG

 Author: Ralph Oliver,  TRANSCOM SYSTEMS