Click or drag to resize

Descend Function

Create a descending order key value.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION Descend(
	uValue AS USUAL
) AS USUAL
View Source

Parameters

uValue
Type: Usual
Any valid expression of string, date, logical, or numeric type.  Memo type is treated in the same way as string type.

Return Value

Type: Usual
An inverted expression of the same data type as the <uValue>, except for dates which return a numeric value.  If <uValue> is Chr(0), Descend() returns Chr(0).
Remarks
Descend() is a conversion function that returns the inverted form of the specified expression.  You can use it as part of the key expression when you create an order with the INDEX command or the DBCreateIndex() or DBCreateOrder() functions.  To subsequently perform a lookup with the SEEK command of DBSeek() function, specify Descend() in the search expression. The preferred way to create a descending order is to use the DESCEND clause of the INDEX command or set the <lDescend> flag to TRUE using the DBSetOrderCondition() before creating the order.  This has the same effect as using the Descend() function in the order key expression, but without the performance penalty during updates.  If you create a descending order in this manner, you do not need to use the Descend() function during a seek operation.
Examples
This example uses Descend() in an order key expression to impose descending date order on the database file:
X#
USE sales NEW
INDEX ON Descend(SaleDate) TO salesdate
Later, use Descend() to SEEK a key value:
X#
SEEK Descend(dFindDate)
You could use the DESCEND keyword instead of Descend(), which is the recommended practice:
X#
USE sales NEW
INDEX ON SaleDate TO salesdate DESCEND
Then, you would seek the key value in the normal  manner:
X#
Sales->DBSeek(dFindDate)
This example illustrates how to create a descending order using more than one data type.  Here, the key is created using the concatenation of date and character fields after the appropriate type conversion has taken place.  This example uses Str() instead of DToS() since Descend() of a date returns a numeric value:
X#
USE sales NEW
INDEX ON Str(Descend(SaleDate)) + salesman TO;
        lastsale
See Also