SEEK

Search an order for a specified key value

Syntax

      SEEK <expSearch> [SOFTSEEK]

Arguments

<expSearch> is an expression to match with an order key value.

SOFTSEEK causes the record pointer to be moved to the next record with a higher key value after a failed order search. Default behavior moves the record pointer to EOF() after a failed order search.

Description

SEEK is a database command that searches the controlling order from the first or last key value (depending on whether the LAST keyword is specified) and proceeds until a match is found or there is a key value greater than <expSearch>. If there is a match, the record pointer is positioned to the identity found in the order. If SOFTSEEK is OFF (the default) and SEEK does not find a match, the record pointer is positioned to LASTREC() + 1, EOF() returns true (.T.), and FOUND() returns false (.F.).

SOFTSEEK enables a method of searching an order and returning a record even if there is no match for a specified key.

When SOFTSEEK is ON and a match for a SEEK is not found, the record pointer is set to the next record in the order with a higher key value than the SEEK argument. Records are not visible because SET FILTER and/or SET DELETED are skipped when searching for the next higher key value. If there is no record with a higher key value, the record pointer is positioned at LASTREC() + 1, EOF() returns true (.T.), and FOUND() returns false (.F.). FOUND() returns true (.T.) only if the record is actually found. FOUND() never returns true (.T.) for a relative find.

When SOFTSEEK is OFF and a SEEK is unsuccessful, the record pointer is positioned at LASTREC() + 1, EOF() returns true (.T.), and FOUND() returns false (.F.).

SEEK with the SOFTSEEK clause is, effectively, the same as performing SET SOFTSEEK and then SEEK in earlier versions of Clipper except that it does not change the global setting of SOFTSEEK.

Examples

      .  The following example searches for "Doe" using the SEEK
         command:

      USE Customer NEW
      SET ORDER TO Customer
      ? SET( _SET_SOFTSEEK )      // (.F.)
      SEEK "Doe"
      ? SET( _SET_SOFTSEEK )      // Still (.F.)
      IF FOUND()
         .
         . < statements >
         .
      ENDIF

      .  The following example performs a soft seek for "Doe" using
         SOFTSEEK clause of the SEEK command:

      USE Customer NEW
      SET ORDER TO Customer
      ? SET( _SET_SOFTSEEK )      // (.F.)
      SEEK "Doe" SOFTSEEK
      ? SET( _SET_SOFTSEEK )      // Still (.F.)
      IF !FOUND()
         ? Customer->Name         // Returns next logical name after "Doe"
      ENDIF

Seealso

DBSEEK(), DBSETINDEX(), DBSETORDER(), EOF(), SET INDEX

Harbour All Functions – D

Date()
Day()
Days()

DaysInMonth()
DaysToMonth()

dbAppend()
dbClearFilter()
dbCloseAll()
dbCloseArea()
dbCommit()
dbCommitAll()
dbCreate()
dbDelete()
dbEval()
dbF()
dbFilter()
dbGoBottom()
dbGoTo()
dbGoTop()
dbReCall()
dbRLock()
dbRLockList()
dbRUnlock()
dbSeek()
dbSelectArea()
dbSetDriver()
dbSetFilter()
dbSkip()
dbSkipper()
dbStruct()
dbUnlock()
dbUnlockAll()
dbUseArea()

DecToBin()
DecToHexa()
DecToOctal()

Deleted()
Descend()
DevOutPict()
DirChange()
DirRemove()
DiskSpace()

DMY()
Do()
DoW()

DOY
DToC()

DToR
DToS()

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

Found()

FOUND()

Determine the success of a previous search operation.

Syntax

      FOUND() --> lSuccess

Arguments

(This function has no arguments)

Returns

<lSuccess> A logical true (.T.) is successful; otherwise, false (.F.)

Description

This function is used to test if the previous SEEK, LOCATE, CONTINUE, or FIND operation was successful. Each wrk area has its own FOUND() flag, so that a FOUND() condition may be tested in unselected work areas by using an alias.

Examples

      nId := 100
      USE tests NEW INDEX tests
      SEEK nId
      IF FOUND()
         ? tests->Name
      ENDIF
      USE

Compliance

Clipper

Files

Library is rdd

Seealso

EOF()

dbSkip()

DBSKIP()

Moves the record pointer in the selected work area.

Syntax

      DBSKIP([<nRecords>])

Arguments

<nRecords> Numbers of records to move record pointer.

Description

This function moves the record pointer <nRecords> in the selected or aliased work area. The default value for <nRecords> will be 1. A DBSKIP(0) will flush and refresh the internal database bufer and make any changes made to the record visible without moving the record pointer in either direction.

Examples

      PROCEDURE Main()
         USE tests NEW
         DBGOTOP()
         DO WHILE ! EOF()
            ? tests->Id, tests->Name
            DBSKIP()
         ENDDO
         USE
         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

BOF(), DBGOBOTTOM(), DBGOTOP(), DBSEEK(), EOF()

dbGoTop()

DBGOTOP()

Moves the record pointer to the top of the database.

Syntax

      DBGOTOP()

Description

This function moves the record pointer in the selected or aliased work area to the top of the file. The position of the record pointer is affected by the values in the index key or by an active FILTER condition. Otherwise, if no index is active or if no filter condition is present, the value of RECNO() will be 1.

Examples

      USE tests
      DBGOTOP()
      ? RECNO()
      DBGOBOTTOM()
      ? RECNO()
      USE

Compliance

Clipper

Files

Library is rdd

Seealso

BOF(), EOF(), DBSKIP(), DBSEEK(), DBGOBOTTOM()

dbGoto()

DBGOTO()

Position the record pointer to a specific location.

Syntax

      DBGOTO(<xRecordNumber>)

Arguments

<xRecordNumber> Record number or unique identity

Description

This function places the record pointer, if working with a .dbf file, in selected or aliased work area at the record number specified by <xRecordNumber>. The position is not affected by an active index or by any enviromental SET condiction.

The parameter <xRecordNumber> may be something other than a record number. In some data formats, for example, the value of <xRecordNumber> is a unique primary key while in other formats, <xRecordNumber> could be an array offset if the data set was an array.

Issuing a DBGOTO(RECNO()) call in a network enviroment will refresh the database and index buffers. This is the same as a DBSKIP(0) call.

Examples

      The following example uses DBGOTO() to iteratively process
      every fourth record:

      DBUSEAREA( .T., "DBFNTX", "sales", "sales", .T. )
      //
      // toggle every fourth record
      DO WHILE ! EOF()
         DBGOTO( RECNO() + 4 )
         sales->Group := "Bear"
      ENDDO

Compliance

Clipper

Files

Library is rdd

Seealso

BOF(), EOF(), DBGOTOP(), DBGOBOTTOM(), DBSEEK(), DBSKIP()

dbGoBottom()

DBGOBOTTOM()

Moves the record pointer to the bottom of the database.

Syntax

      DBGOBOTTOM()

Description

This function moves the record pointer in the selected or aliased work area to the end of the file. The position of the record pointer is affected by the values in the index key or by an active FILTER condition. Otherwise, if no index is active or if no filter condition is present, the value of the record pointer will be LASTREC().

Examples

      USE tests
      DBGOTOP()
      ? RECNO()
      DBGOBOTTOM()
      ? RECNO()
      USE

Compliance

Clipper

Files

Library is rdd

Seealso

BOF(), EOF(), DBSKIP(), DBSEEK(), DBGOTOP()

SP_SPOPSEEK

SPOPSEEK()

  Short:
  ------
  SPOPSEEK() Popup seek based on present index keys

  Returns:
  --------
  <lFound> => seek succesful or not

  Syntax:
  -------
  SPOPSEEK([aKeys])

  Description:
  ------------
  Pops up first a box asking for which index selection,
  and when the index key is selected, asks for a value to be
  entered to seek on. Performs a seek and returns <lFound>
  success. The index order is saved and restored.

  [aKeys] is an optional array of current index keys.

  Examples:
  ---------
   IF choice = POP_SEEK
      if SPOPSEEK()
        redrawscreen()
      endif
   ENDIF

  Source:
  -------
  S_PSEEK.PRG

 

C5_DBSEEK

 DBSEEK() 
 Move to the record having the specified key value
------------------------------------------------------------------------------
 Syntax

     DBSEEK(<expKey>, [<lSoftSeek>], [<lLast>]) --> lFound

 Arguments

     <expKey> is a value of any type that specifies the key value
     associated with the desired record.

     <lSoftSeek> is an optional logical value that specifies whether a
     soft seek is to be performed.  This determines how the work area is
     positioned if the specified key value is not found (see below).  If
     <lSoftSeek> is omitted, the current global _SET_SOFTSEEK setting is
     used.

     <lLast> is specified as true (.T.) to seek the last occurrence of
     the specified key value.  False (.F.), the default, seeks the first
     occurrence.

     Note:  This parameter is only supported for specific RDDs.  DBFNTX
     is NOT one of them.

 Returns

     DBSEEK() returns true (.T.) if the specified key value was found;
     otherwise, it returns false (.F.).

 Description

     DBSEEK() moves to the first logical record whose key value is equal to
     <expKey>.  If such a record is found, it becomes the current record and
     DBSEEK() returns true (.T.); otherwise, it returns false (.F.).  the
     positioning of the work area is as follows: for a normal (not soft)
     seek, the work area is positioned to LASTREC() + 1 and EOF() returns
     true (.T.); for a soft seek, the work area is positioned to the first
     record whose key value is greater than the specified key value.  If no
     such record exists, the work area is positioned to LASTREC() + 1 and
     EOF() returns true (.T.).

     For a work area with no active indexes, DBSEEK() has no effect.

     DBSEEK() performs the same function as the standard SEEK command.  For
     more information, refer to the SEEK command.

 Notes

     .  Logical records:  DBSEEK() operates on logical records which
        are considered in indexed order.  If a filter is set, only records
        which meet the filter condition are considered.

     .  Controlling order:  If the work area has more than one active
        index, the operation is performed using the controlling order as set
        by DBSETORDER() or the SET ORDER command.  For more information,
        refer to the SET ORDER command.

     .  Network environment:  For a shared file on a network, moving
        to a different record may cause updates to the current record to
        become visible to other processes.  For more information, refer to
        the "Network Programming" chapter in the Programming and Utilities
        Guide.  This function will not affect the locked status of any
        record.

 Examples

     .  In this example, DBSEEK() moves the pointer to the record in
        the database, Employee, in which the value in FIELD "cName" matches
        the entered value of cName:

        ACCEPT "Employee name: " TO cName
        IF ( Employee->(DBSEEK(cName)) )
           Employee->(VIEWRECORD())
        ELSE
           ? "Not found"
        END

 Files   Library is CLIPPER.LIB.

See Also: DBGOBOTTOM() DBGOTOP() DBSKIP() EOF() FOUND()