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

C5_DBSETORDER

 DBSETORDER()
 Set the controlling order
------------------------------------------------------------------------------
 Syntax

     DBSETORDER(<nOrderNum>) --> NIL

 Arguments

     <nOrderNum> is a numeric value that specifies which of the active
     indexes is to be the controlling index.

 Returns

     DBSETORDER() always returns NIL.

 Description

     DBSETORDER() controls which of the current work area's active indexes is
     the controlling index.  The controlling index is the index which
     determines the logical order of records in the work area.

     Active indexes are numbered from 1 to the number of active indexes,
     based on the order in which the indexes were opened.  <nOrderNum>
     specifies the number of the desired index.

     DBSETORDER() performs the same function as the standard SET ORDER
     command.  For more information, refer to the SET ORDER command.

 Notes

     .  Setting order to zero: Setting order to zero causes the work
        area to be accessed in natural (record number) order.  Only the
        logical order of the records is affected; any open indexes continue
        to be active and are properly maintained.

 Examples

     .  This example sets the second named index, Age, as the
        controlling index:

        USE Employee NEW
        SET INDEX TO Name, Age
        DBSETORDER(2)

 Files   Library is CLIPPER.LIB.


See Also: DBCLEARIND() DBCREATEIND() DBREINDEX() DBSETINDEX()

 

C5 Index Commands and Functions

Index Commands and Functions

Commands :

DELETE TAG :

Delete a Tag

DELETE TAG <cOrderName> [IN <xcOrderBagName>]
    [, <cOrderName> [IN xcOrderBagName] list>]

INDEX ON … :

Create an index file

INDEX ON <expKey>
    [TAG <cOrderName>]
    TO <xcOrderBagName>
    [FOR <lCondition>] [ALL]
    [WHILE <lCondition>]
    [NEXT <nNumber>]
    [RECORD <nRecord>]
    [REST]
    [EVAL <bBlock>
    [EVERY <nInterval>]
    [UNIQUE]
    [ASCENDING|DESCENDING]

REINDEX :

Rebuild open indexes in the current workarea

REINDEX
    [EVAL <lCondition>]
    [EVERY <nRecords>]]

SET INDEX

Open index file(s) in the current work area

SET INDEX TO [<xcIndex list>]

SET ORDER

Set a new controlling index

SET ORDER TO [<nOrder> | [TAG <cOrderName>]
    [IN <xcOrderBagName>]]>

SET UNIQUE* : 

Toggle the inclusion of nonunique keys into an index

SET UNIQUE on | OFF | <xlToggle>

Functions :

DBCLEARINDEX() :

Close all indexes for the current work area

DBCLEARINDEX() --> NIL

DBCREATEINDEX() :

Create an index file

DBCREATEINDEX( <cIndexName>, <cKeyExpr>,
    <bKeyExpr>, 
    [<lUnique>] ) --> NIL

DBREINDEX() : 

Recreate all active indexes for the current work area

DBREINDEX() --> NIL

DBSEEK() : 

Move to the record having the specified key value

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

DBSETINDEX() : 

Open an index for the current work area

 DBSETINDEX( <cIndexName> ) --> NIL
 DBSETINDEX( <cOrderBagName> ) --> NIL

DBSETORDER() : 

Set the controlling order for the current work area

DBSETORDER( <nOrderNum> ) --> NIL

DESCEND() : 

Return a descending index key value

DESCEND( <exp> ) --> ValueInverted

FOUND() : 

Determine if the previous search operation succeeded

FOUND() --> lSuccess

INDEXEXT() : 

Return the default index extension

INDEXEXT() --> cExtension

INDEXKEY() : 

Return the key expression of a specified index

INDEXKEY( <nOrder> ) --> cKeyExp

INDEXORD() : 

Return the order position of the controlling index

INDEXORD() --> nOrder

ORDBAGEXT() :

Return the default Order Bag RDD extension

ORDBAGEXT() --> cBagExt

ORDBAGNAME() :

Return the Order Bag name of a specific Order

ORDBAGNAME(<nOrder> | <cOrderName>) --> cOrderBagName

ORDCOND()

Specify conditions for ordering

ORDCOND([FOR <lCondition>]
             [ALL] [WHILE <;lCondition>]
             [EVAL <bBlock> [EVERY <nInterval>]]
             [RECORD <nRecord>] [NEXT <nNumber>]
             [REST] [DESCENDING])

ORDCONDSET()

Set the condition and scope for an order

     ORDCONDSET([<cForCondition>],
        [<bForCondition>],
        [<lAll>],
        [<bWhileCondition>],
        [<bEval>],
        [<nInterval>],
        [<nStart>],
        [<nNext>],
        [<nRecord>],
        [<lRest>],
        [<lDescend>],
        [<lAdditive>],
        [<lCurrent>],
        [<lCustom>],
        [<lNoOptimize>]) --> lSuccess

ORDCREATE():

Create an Order in an Order Bag

ORDCREATE(<cOrderBagName>,[<cOrderName>], <cExpKey>,

    [<bExpKey>], [<lUnique>]) --> NIL

ORDDESCEND()

Return and optionally change the descending flag of an order

ORDDESCEND([<cOrder> | <nPosition>],[<cIndexFile>],
            [<lNewDescend>]) --> lCurrentDescend

ORDDESTROY() :

Remove a specified Order from an Order Bag

ORDDESTROY(<cOrderName> [, <cOrderBagName> ]) --> NIL

ORDFOR() :

Return the FOR expression of an Order

ORDFOR(<cOrderName> | <nOrder>
    [, <cOrderBagName>]) --> cForExp

ORDISUNIQUE()

          Return the status of the unique flag for a given order

    ORDISUNIQUE([<cOrder> | <nPosition>],
        [<cIndexFile>]) --> lUnique

ORDKEY() :

Return the Key expression of an Order

ORDKEY(<cOrderName> | <nOrder>
 [, <cOrderBagName>]) --> cExpKey

ORDKEYADD()

Add a key to a custom built order

         ORDKEYADD([<cOrder> | <nPosition>],
            [<cIndexFile>],[<expKeyValue>]) --> lSuccess

 

ORDKEYCOUNT()

Return the number of keys in an order

         ORDKEYCOUNT([<cOrder> | <nPosition>],
              [<cIndexFile>]) --> nKeys

ORDKEYDEL()

Delete a key from a custom built order

        ORDKEYDEL([<cOrder> | <nPosition>],
            [<cIndexFile>],
            [<expKeyValue>]) --> lSuccess

ORDKEYGOTO()

Move to a record specified by its logical record number

ORDKEYGOTO(<nKeyNo>) --> lSuccess

ORDKEYNO()

 Get the logical record number of the current record

         ORDKEYNO([<cOrder> | <nPosition>],
             [<cIndexFile>]) --> nKeyNo

 ORDKEYVAL()

Get key value of the current record from controlling order

ORDKEYVAL() --> xKeyValue

 

ORDLISTADD() :

Add Order Bag contents or single Order to the Order List

ORDLISTADD(<cOrderBagName>
    [, <cOrderName>]) --> NIL

ORDLISTCLEAR() :

Clear the current Order List

ORDLISTCLEAR() --> NIL

ORDLISTREBUILD() :

Rebuild all Orders in the Order List of the current work area

ORDLISTREBUILD() --> NIL

ORDNAME() :

Return the name of an Order in the work area

ORDNAME(<nOrder>[,<cOrderBagName>])
    --> cOrderName

ORDNUMBER() :

Return the position of an Order in the current Order List

ORDNUMBER(<cOrderName>[, <cOrderBagName>]) --> nOrderNo

 ORDSCOPE()

Set or clear the boundaries for scoping key values

ORDSCOPE(<nScope>, [<expNewValue>]) --> uCurrentValue

ORDSETFOCUS() :

Set focus to an Order in an Order List

ORDSETFOCUS([<cOrderName> | <nOrder>]
    [,<cOrderBagName>]) --> cPrevOrderNameInFocus

ORDSETRELAT()

Relate a specified work area to the current work area

    ORDSETRELATION(<nArea> | <cAlias>,<bKey>, [<cKey>])

             --> NIL

ORDSKIPUNIQUE()

Move record pointer to the next or previous unique key

ORDSKIPUNIQUE([<nDirection>]) –> lSuccess