IndexOrd()

INDEXORD()

Returns the numeric position of the controlling index.

Syntax

      INDEXORD() --> <nPosition>

Arguments

None.

Returns

<nPosition> Ordinal position of a controling index

Description

The INDEXORD() function returns the numeric position of the current controlling index in the selected or designated work area. A returned value of 0 indicated that no active index is controlling the database, which therefore is in the natural order.

Examples

      USE tests NEW INDEX test1
      IF INDEXORD() > 0
         ? "Current order is", INDEXORD()
      ENDIF

Compliance

Clipper

Platforms

All

Files

Library is rdd

Seealso

INDEXKEY()

IndexExt()

INDEXEXT()

Returns the file extension of the index module used in an application

Syntax

      INDEXEXT() --> <cExtension>

Arguments

None.

Returns

<cExtension> Current driver file extension

Description

This function returns a string that tells what indexes are to be used or will be created in the compiled application. The default value is “.ntx”. This is controled by the particular database driver that is linked with the application.

Examples

      IF INDEXEXT() == ".ntx"
         ? "Current driver being used is DBFNTX"
      ENDIF

Compliance

Clipper

Platforms

All

Files

Library is rdd

Seealso

INDEXKEY(), INDEXORD()

C5_INDEXKEY

 INDEXKEY()
 Return the key expression of a specified index
------------------------------------------------------------------------------
 Syntax

     INDEXKEY(<nOrder>) --> cKeyExp

 Arguments

     <nOrder> is the ordinal position of the index in the list of index
     files opened by the last USE...INDEX or SET INDEX TO command for the
     current work area.  A zero value specifies the controlling index,
     without regard to its actual position in the list.

 Returns

     INDEXKEY() returns the key expression of the specified index as a
     character string.  If there is no corresponding index or if no database
     file is open, INDEXKEY() returns a null string ("").

 Description

     INDEXKEY() is a database function that determines the key expression of
     a specified index in the current work area and returns it as a character
     string.  To evaluate the key expression, specify INDEXKEY() as a macro
     expression like this: &(INDEXKEY(<nOrder>)).

     INDEXKEY() has a number of applications, but two specific instances are
     important.  Using INDEXKEY(), you can TOTAL on the key expression of the
     controlling index without having to specify the key expression in the
     source code.  The other instance occurs within a DBEDIT() user function.
     Here, you may want to determine whether or not to update the screen
     after the user has edited a record.  Generally, it is only necessary to
     update the screen if the key expression of the controlling index has
     changed for the current record.  Both of these examples are illustrated
     below.

     By default, INDEXKEY() operates on the currently selected work area.  It
     can be made to operate on an unselected work area by specifying it
     within an aliased expression (see example below).

 Examples

     .  This example accesses the key expression of open indexes in
        the current work area:

        #define ORD_NATURAL      0
        #define ORD_NAME         1
        #define ORD_SERIAL      2
        //
        USE Customer INDEX Name, Serial NEW
        SET ORDER TO ORD_SERIAL
        ? INDEXKEY(ORD_NAME)         // Result: Name index exp
        ? INDEXKEY(ORD_SERIAL)      // Result: Serial index exp
        ? INDEXKEY(ORD_NATURAL)      // Result: Serial index exp

     .  This example accesses the key expression of the controlling
        index in an unselected work area:

        USE Customer INDEX Name, Serial NEW
        USE Sales INDEX Salesman NEW
        ? INDEXKEY(0), Customer->(INDEXKEY(0))

     .  This example uses INDEXKEY() as part of a TOTAL ON key
        expression.  Notice that INDEXKEY() is specified using a macro
        expression to force evaluation of the expression:

        USE Sales INDEX Salesman NEW
        TOTAL ON &(INDEXKEY(0)) FIELDS SaleAmount TO ;
              SalesSummary

     .  This example uses INDEXKEY() to determine whether the DBEDIT()
        screen should be updated after the user has edited the current field
        value.  Generally, you must update the DBEDIT() screen if the user
        changes a field that is part of the controlling index key.
        FieldEdit() is a user-defined function called from a DBEDIT() user
        function to edit the current field if the user has pressed an edit
        key.

        #include "Dbedit.ch"
        #define ORD_NATURAL   0
        FUNCTION FieldEdit()
           LOCAL indexVal
           // Save current key expression and value
           indexVal = &(INDEXKEY(ORD_NATURAL))
           .
           . <code to GET current field value>
           .
           // Refresh screen if key value has changed
           IF indexVal != &(INDEXKEY(ORD_NATURAL))
              nRequest = DE_REFRESH
           ELSE
              nRequest = DE_CONT
           ENDIF
           RETURN nRequest

 Files   Library is CLIPPER.LIB.

See Also: INDEX INDEXEXT() INDEXORD() SET INDEX SET ORDER



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