xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

OrdDescend()

Determines the navigational order of a work area.

Syntax

OrdDescend( [<cIndexName> | <nOrder>], ;
            [<cIndexFile>]           , ;
            [<lNewDescendFlag>]        ) --> lOldDescendFlag

Arguments

<cIndexName>
This is a character string holding the symbolic name of the index to query. It is analogous to the alias name of a work area. Support for <cIndexName> depends on the RDD used to create the index. Usually, RDDs that are able to maintain multiple indexes in one index file support symbolic index names, such as DBFCDX, for example.
<nOrder>
Optionally, a numeric value specifying the ordinal position of the index open in a work area. Indexes are numbered in the sequence of opening, beginning with 1. The value zero identifies the controlling index.
<cIndexFile>
<cIndexFile> is a character string with the name of the file that stores the index. It is only required when multiple index files are open that contain indexes having the same <cIndexName>.
<lNewDescendFlag>
A logical value can be passed for <lNewDescendFlag>. It changes the descend flag of the index. When .T. (true) is specified, the navigational order in the current work area is set to descending, .F. (false) sets the navigational order to ascending.

Return

The function returns the descend flag set before the function is called.

Description

The function OrdDescend() is used to change the descend flag dynamically at runtime. The navigational order in a work area can be changed from ascending to descending and back without having to create a corresponding index. When .T. (true) is passed to the function, the navigational order is reversed, i.e. all functions and commands which move the record pointer are reversed.

Descending navigation
FunctionDescription
Bof()Returns .T. when the last record is reached.
Eof()Returns .T. when the first record is reached.
DbSkip( 1 )Moves the record pointer to the previous record.
DbSkip(-1 )Moves the record pointer to the next record.
DbGoTop()Moves the record pointer to the last record.
DbGoBottom()Moves the record pointer to the first record.

Note:  the function changes the descending flag at runtime only. It does not change the actual index file.

Info

See also:DbOrderInfo(), INDEX, OrdCondSet(), OrdCustom()
Category: Database functions , Index functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example creates an ascending index and demonstrates
// the effect when the navigational order is reversed.

   PROCEDURE Main
      USE Customer
      INDEX ON Upper(Lastname+Firstname) TO Cust01

      GO TOP
      ? LastName               // result: Alberts
      GO BOTTOM
      ? LastName               // result: Waters

      OrdDescend( ,, .T. )     // change navigational order

      SKIP -1                  // skipping backwards from the last
                               // record hits begin of file.
      ? Bof()                  // result: .T.

      GO BOTTOM
      ? Eof()                  // result: .F.
      ? LastName               // result: Alberts

      SKIP
      ? Eof()                  // Result: .T.

      GO TOP
      ? LastName               // result: Waters

      USE
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe