xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Descend()

Converts a value for a descending index.

Syntax

Descend( <xValue> ) --> xDescend

Arguments

<xValue>
An expression whose value must be of data type Character, Date, Logic or Numeric.

Return

The function returns the converted value suitable for creating a descending index. The data type is the same as for <xValue>, except for Date values. The converted value for Dates is of numeric data type.

Description

Descend() is a utility function that can be used for the creation of a descending index. The argument passed to Descend() is converted so that the resulting value is sorted logically like the initial value in descending order. Any portion of an index expression can include the Descend() function. This allows for sorting partial index expressions in descending order. Any subsequent SEEK operations must convert the searched value using Descend().

If the entire index should be created in descending order, it is recommended to use the DESCENDING option of the INDEX command. This is advantageous since searched values do not need to be converted with Descend().

Info

See also:CtoD(), DbSeek(), DtoC(), DtoS(), INDEX, OrdCondSet(), OrdCreate(), OrdDescend(), SEEK, Str(), Val()
Category: Conversion functions
Source:rtl\descend.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example creates a descending index using the Descend()
// function and outlines how to search in such an index with SEEK.

   PROCEDURE Main

      ? Descend( 789 )                // result: -789

      USE Customer NEW
      INDEX ON Descend(Upper(Lastname)) TO Temp

      GO TOP
      ? FIELD->Lastname               // result: Waters

      GO BOTTOM
      ? FIELD->Lastname               // result: Alberts

      SEEK Descend( "KELLER" )

      ? FIELD->Lastname               // result: Keller

      USE
   RETURN

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