Harbour All Functions – A

AAdd
Abs
AChoice
AClone
ACopy
ACos

ADays
AddASCII
AddMonth
ADel
ADir
AfterAtNum
AEval
AFields
AFill
AIns
Alert
Alias
AllTrim

AMonths
Array
Asc
AScan
ASCIISum
ASCPos
ASin
ASize
ASort
At
AtAdjust
ATail
ATan
ATn2
AtNum
AtRepl
AtToken

Harbour Database Functions

Database Functions

AFields Fills referenced arrays with database field information
Alias Returns the alias name of a work area
BOF Test for the beggining-of-file condition
dbAppend Appends a new record to a database file
dbClearFilter Clears the current filter condiction in a work area
dbCloseAll Close all open files in all work areas.
dbCloseArea Close a database file in a work area
dbCommit Updates all index and database buffers for a given workarea
dbCommitAll Flushes the memory buffer and performs a hard-disk write
dbCreate Creates an empty database from a array
dbDelete Mark a record for deletion in a database
dbEval Performs a code block operation on the current Database
DBF Alias name of a work area
dbFilter Return the filter expression in a work area
dbGoBottom Moves the record pointer to the bottom of the database
dbGoto Position the record pointer to a specific location
dbGoTop Moves the record pointer to the top of the database
dbRecall Recalls a record previousy marked for deletion
dbSeek Searches for a value based on an active index
dbSelectArea Change to another work area
dbSetDriver Establishes the RDD name for the selected work area
dbSetFilter Establishes a filter condition for a work area
dbSkip Moves the record pointer in the selected work area
dbSkipper Helper function to skip a database
dbStruct Builds a multidimensional array of a database structure
dbUseArea Opens a work area and uses a database file
Deleted Tests the record’s deletion flag
EOF Test for end-of-file condition
FCount Counts the number of fields in an active database
FieldDeci Determines the number of decimal places of a given numeric field
FieldGet Obtains the value of a specified field
FieldName Return the name of a field at a numeric field location
FieldPos Return the ordinal position of a field
FieldPut Set the value of a field variable
FieldSize Determines the size of a given field
FieldType Determines the type of a given field
Found Determine the success of a previous search operation
Header Return the length of a database file header
LastRec Returns the number of records in an active work area or database
LUpdate Yields the date the database was last updated
RecCount Counts the number of records in a database
RecNo Returns the current record number or identity
RecSize Returns the size of a single record in an active database
Select Returns the work area number for a specified alias
Used Checks whether a database is in use in a work area

dbStruct()

DBSTRUCT()

Creates a multidimensional array of a database structure.

Syntax

      DBSTRUCT() --> aStruct

Returns

DBSTRUCT() returns an array pointer to database structure

Description

This function returns a multidimensional array. This array has array pointers to other arrays, each of which contains the characteristic of a field in the active work area. The lenght of this array is based in the number of fields in that particular work area. In other words, LEN(DBSTRUCT()) is equal to the value obtained from FCOUNT(). Each subscript position

Examples

      #include "dbstruct.ch"
      PROCEDURE Main()
         LOCAL aStru, x
         USE tests NEW
         aStru := dbStruct()
         FOR x := 1 TO LEN( aStru )
            ? aStru[ x ][ DBS_NAME ]
         NEXT
         USE
         RETURN

Compliance

Clipper

Files

Library is rdd Header is dbstruct.ch

Seealso

AFIELDS()*

dbCreate()

DBCREATE()

Creates an empty database from a array.

Syntax

      DBCREATE( <cDatabase>, <aStruct>, [<cDriver>], [<lOpen>],
                [<cAlias>] )

Arguments

<cDatabase> Name of database to be create

<aStruct> Name of a multidimensional array that contains the database structure

<cDriver> Name of the RDD

<lOpenNew> 3-way toggle to Open the file in New or Current workarea:

                       NIL     The file is not opened.
                       True    It is opened in a New area.
                       False   It is opened in the current area.

<cAlias> Name of database Alias

Description

This function creates the database file specified as <cDatabase> from the multidimensional array <aStruct>. If no file extension is use with <cDatabase> the .dbf extension is assumed. The array specified in <aStruct> must follow a few guidelines when being built prior to a call to DBCREATE():

– All subscripts values in the second dimension must be set to proper values

– The fourth subscript value in the second dimension – which contains the decimal value-must he specified. even 1kw nonnumeric fields.

– The second subscript value in the second dimension-which contains the field data type-must contain a proper value: C, D, L, M or N It is possible to use additional letters (or clarity (e.g., ‘Numeric’ for ‘N’): however, the first letter of this array element must be a proper value.

The DBCREATE( ) function does not use the decimal field to calculate the length of a character held longer than 256. Values up to the maximum length of a character field (which is 65, 519 bytes) are stored directly in the database in the length attribute if that database was created via this function. However, a file containing fields longer than 256 bytes is not compatible with any interpreter.

The <cDriver> parameter specifies the name of the Replaceable Database Driver to use to create the database. If it is not specified, then the Replaceable Database Driver in the current work area is used.

The <lOpenNew> parameter specifies if the already created database is to be opened, and where. If NIL, the file is not opened. If True, it is opened in a New area, and if False it is opened in the current area (closing any file already occupying that area). The <cAlias> parameter specifies the alias name for the new opened database.

Examples

      PROCEDURE Main()
         LOCAL nI, aStruct := { { "CHARACTER", "C", 25, 0 }, ;
                                { "NUMERIC",   "N",  8, 0 }, ;
                                { "DOUBLE",    "N",  8, 2 }, ;
                                { "DATE",      "D",  8, 0 }, ;
                                { "LOGICAL",   "L",  1, 0 }, ;
                                { "MEMO1",     "M", 10, 0 }, ;
                                { "MEMO2",     "M", 10, 0 } }

         REQUEST DBFCDX

         dbCreate( "testdbf", aStruct, "DBFCDX", .T., "MYALIAS" )

         RETURN

Compliance

This function is not CA-Cl*pper compliant

Files

Library is rdd Header is dbstruct.ch

Seealso

AFIELDS()*, DBSTRUCT()

SP_FILLARR

FILLARR()

  Short:
  ------
  FILLARR() Fill type, length, decimal arrays

  Returns:
  --------
  Nothing - works on arrays passed

  Syntax:
  -------
  FILLARR(aNames,aTypes,[aLens],[aDeci])

  Description:
  ------------
  Fills in TYPE <aTypes> , LENGTH [aLens] and DECIMAL
  [aDeci] arrays given a FIELDNAME array <aNames>.

  Arrays (3 and 4) are optional.

  Examples:
  ---------
   nFields   :=LEN(aFieldNames)
   aFldtypes     := array(nFields)
   aFldLens      := array(nFields)
   aFldDeci      := array(nFields)
   FILLAR(aFieldNames,aFldTypes,aFldLens,aFldDeci)

  Warnings:
  ----------
  Macro expands an expression to obtain type-could
  crash if expression passed is invalid. Not really meant for
  expressions, but people will pass them from time to time.

  Notes:
  -------
  In most circumstances you would fill all of these
  arrays with one call to AFIELDS(), but there are exceptions.

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

 

SP_AFLENSX

AFLENSX()

  Short:
  ------
  AFLENSX() Returns an array of field LENGTHS for current dbf

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

  Syntax:
  -------
  AFLENSX()

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

  Examples:
  ---------
   aArray := AFIELDSX()
   aTypes := AFTYPESX()
   aLens  := AFLENSX()
   aDeci  := AFDECIX()

   if (nSelect := mchoice(aArray,10,10,20,20,"Pick Field")) >  0
      ?"Field "+aArray[nSelect]+" was selected"
      ?" of type     "+aTypes[nSelect]
      ?" of length   "+aLens[nSelect]
      ?" of decimals "+aDeci[nSelect]
   endif

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

 

SP_AFIELDSX

AFIELDSX()

  Short:
  ------
  AFIELDSX() Returns an array of field names for current dbf

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

  Syntax:
  -------
  AFIELDSX()

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

  Examples:
  ---------

   aArray := AFIELDSX()
   nSelect :=   mchoice( aArray ,10,10,20,20,"Pick Field")
   if  nSelect > 0
     ?"Field "+aArray[nSelect]+" was selected"
   endif

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

 

SP_AFDECIX

AFDECIX()

  Short:
  ------
  AFDECIX() Returns an array of field DECIMALS for current dbf

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

  Syntax:
  -------
  AFDECIX()

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

  Examples:
  ---------
   aArray := AFIELDSX()
   aDeci  := AFDECIX()
   if (nSelect := mchoice(aArray,10,10,20,20,"Pick Field")) > 0
      ?"Field "+aArray[nSelect]+" was selected"
      ?" with  decimals "+aDeci[nSelect]
   endif

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