Harbour All Functions – F

















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


 Return the position of a field in a work area

     FIELDPOS(<cFieldName>) --> nFieldPos


     <cFieldName> is the name of a field in the current or specified work


     FIELDPOS() returns the position of the specified field within the list
     of fields associated with the current or specified work area.  If the
     current work area has no field with the specified name, FIELDPOS()
     returns zero.


     FIELDPOS() is a database function that is the inverse of the FIELDNAME()
     function.  FIELDPOS() is most often used with the FIELDPUT() and
     FIELDGET() functions.

     FIELDPOS() return the names of fields in any unselected work area by
     referring to the function using an aliased expression.  See the example


     .  This example demonstrates a typical specification of the
        FIELDPOS() function:

        USE Customer NEW
        ? FIELDPOS("Name")                     // Result: 1
        ? FIELDGET(FIELDPOS("Name"))           // Result: Kate

     .  This example uses FIELDPOS() to return the position of a
        specified field in a unselected work area:

        USE Customer NEW
        USE Invoices NEW
        ? Customer->(FIELDPOS("Name"))         // Result: 1
        ? Customer->(FIELDGET(FIELDPOS("Name")))
                                               // Result: Kate

 Files   Library is CLIPPER.LIB.


-> Alias assignment

 Alias assignment--binary                        (Special)



     <idAlias> is the name of the unselected work area to access and must
     refer to a work area with a database file in USE.

     <nWorkArea> is the number of the unselected work area to access.

     <idField> is the name of a field in the specified work area.

     <exp> is an expression of any data type to be executed in the
     specified work area.  If an expression more complicated than a single
     field reference is used as the second operand, the expression must be
     enclosed in parentheses ( ).

     <idVar> is any valid CA-Clipper identifier.  Depending on whether
     you specify FIELD or MEMVAR, the identifier will be forced to a database
     field or memory variable (public or private) reference.


 When used with an <idAlias> as the first operand, the alias operator

     (->) accesses field information or evaluates an expression in the
     indicated work area.  The alias operator implicitly SELECTs the
     <idAlias> before evaluating the <idField> or <exp> operand.  When the
     evaluation is complete, the original work area is SELECTed again.  An
     alias reference can be in an expression or on a line by itself:

     ? Customer->Name

     Using the alias operator lets you:

     .  Access information from unselected work areas within

     .  Access environmental information from unselected work areas

     .  Access information from unselected work areas in modes such as
        REPORT and LABEL FORMs

     .  Write more compact code

     In addition to allowing expression and field evaluation in unselected
     work areas, the alias operator makes an explicit reference to a field or
     variable using either the FIELD or the MEMVAR keyword aliases.  MEMVAR
     forces <idVar> to refer to a memory variable name, and FIELD forces it
     to reference a database field.  These special alias identifiers allow
     you to avoid ambiguity when there are conflicts between field and memory
     variable names.  Remember that a reference to a variable identifier not
     prefaced with an alias defaults to a field if there are both field and
     memory variables with the same name.  To override this, use the (/V)
     option when compiling.

     In addition to specifying the alias as an identifier, you can access the
     target work area using an expression that returns the work area number
     if the expression is enclosed by parentheses.  This lets you use work
     area numbers as handles, which is useful for passing references to work
     areas without using macros, aliases, names, etc.


     .  This example accesses database and work area information in an
        unselected work area:

        USE Customer NEW
        USE Invoices NEW
        ? Customer->CustName                  // Result: Bill Smith
        ? Customer->(RECNO())                 // Result: 1
        ? Customer->(FOUND())                 // Result: .F.
        ? Customer->(City + ", " + State + ;
           "  " + Zip)                        // Result: ShadowVille,
                                              //         CA  90415

     .  This example uses a user-defined function (MySeek()) as an
        operand of the alias operator for a common operation that normally
        requires many more statements:

        IF Invoices->(MySeek(CustNum))
           <process customer>...
           <process no find>...

        FUNCTION MySeek( cSearch )
           SEEK cSearch
        RETURN (FOUND())

        Note:  This example is just an illustration of the alias operator
        with a user-defined function.  CA-Clipper's DBSEEK() could be used
        instead of MySeek().

     .  This example explicitly references field and memory variables
        with the same name:

        USE Customer NEW
        MEMVAR->CustName = "Bill Smith"      // Create a memvar
                                             // CustName
        LOCATE FOR MEMVAR->CustName = FIELD->CustName

     .  This example uses an expression as a work area handle to
        create a work area-independent database operation:

        cTable1 := "C:Myfile.dbf"
        cTable2 := "D:Myfile.dbf"
        USE (cTable1) NEW
        hArea1 = SELECT()
        USE (cTable2) NEW
        hArea2 = SELECT()
        DoStuff( hArea1, hArea2 )

        FUNCTION DoStuff( hArea1, hArea2 )
           LOCAL nCount, nSave
           nSave := SELECT()
           SELECT (hArea1)
           FOR nCount := 1 TO FCOUNT()
              FIELDPUT( nCount, ( hArea2 )-> ;
                 ( FIELDGET( nCount )))
           SELECT (nSave)
           RETURN NIL