Click or drag to resize

DbOrderInfo Function

X#
Return and optionally change information about orders and index files.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION DbOrderInfo(
	kInfoType,
	cIndexFile,
	uOrder,
	uNewSetting
) AS USUAL CLIPPER
Request Example View Source

Parameters

kInfoType (Optional)
Type: Usual
Specifies the type of information.
The constants are listed in the remarks section below. Note, however, that not all constants are supported for all RDDs.
cIndexFile (Optional)
Type: Usual
The name of an index file, including an optional drive and directory (no extension should be specified).
Use this argument with cOrder to remove ambiguity when there are two or more orders with the same name in different index files.
If cIndexFile is not open by the current process, a runtime error is raised.
uOrder (Optional)
Type: Usual
The name of the order about which you want to obtain information or a number representing its position in the order list. (For single-order index files, the order name is the eight-letter index file name.)
Using the order name is the preferred method since the position may be difficult to determine using multiple-order index files. Invalid values are ignored.
If no index file or order is specified, the controlling order is assumed.
uNewSetting (Optional)
Type: Usual
If specified, this parameter is used to change the value of a setting.
The data type (and whether uNewSetting can be specified), depends on the kInfoType constant and is documented in the Remarks section below.

Return Value

Type: Usual
If uNewSetting is not specified, DBOrderInfo() returns the current setting.
If uNewSetting is specified, the previous setting is returned.
Remarks
By default, this function 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
Examples
This example uses DBOI_NAME to save the current controlling order.
After changing to a new controlling order, it uses the saved value to restore the original order:
X#
1USE customer INDEX name, serial NEW
2cOrder := DBOrderInfo(DBOI_NAME)        // name
3Customer->DBSetOrder("serial")
4? DBOrderInfo(DBOI_NAME)            // serial
5Customer->DBSetOrder(cOrder)
6? DBOrderInfo(DBOI_NAME)            // name
This example uses aliased expressions to return the default index file extension (using DBOI_INDEXEXT) in two different work areas:
X#
1USE sales INDEX all_sales VIA "DBFCDX" NEW
2USE customer INDEX name, serial VIA "DBFNTX" NEW
3? Sales->DBOrderInfo(DBOI_INDEXEXT)    // .CDX
4? Customer->DBOrderInfo(DBOI_INDEXEXT)    // .NTX
In this example, DBOrderInfo(DBOI_INDEXEXT) checks for the existence of the CUSTOMER index file independent of the RDD linked into the current work area:
X#
1USE customer NEW
2IF !File("customer" + DBOrderInfo(DBOI_INDEXEXT))
3    Customer->DBCreateIndex("customer", "CustName",;
4        {|| Customer->CustName})
5ENDIF
This example accesses the key expression of several orders from the same index file:
X#
1USE customer INDEX all_cust VIA "DBFMDX" NEW
2Customer->DBSetOrder("serial")
3? DBOrderInfo(DBOI_EXPRESSION,, "name")
4// Result: key expression for name order
5? DBOrderInfo(DBOI_EXPRESSION,, "serial")
6// Result: key expression for serial order
This example uses DBOrderInfo() as part of a TOTAL ON key expression. Since DBOrderInfo() returns the expression as a string, it is specified using a macro expression to force evaluation of the key expression:
X#
1USE sales INDEX salesman NEW
2TOTAL ON &(DBOrderInfo(DBOI_EXPRESSION)) ;
3    FIELDS SaleAmount TO summary
In this example, ALL_CUST.MDX contains three orders named CUACCT, CUNAME, CUZIP.
The DBOI_INDEXNAME constant is used to display the name of the index file using one of its orders:
X#
1USE customer VIA "DBFNTX" NEW
2Customer->DBSetIndex("all_cust")
3? DBOrderInfo(DBOI_INDEXNAME,, "cuname")
4// Returns: all_cust
The following example searches for CUNAME in the order list:
X#
1USE customer VIA "DBFNTX" NEW
2Customer->DBSetIndex("cuacct")
3Customer->DBSetIndex("cuname")
4Customer->DBSetIndex("cuzip")
5? DBOrderInfo(DBOI_NUMBER,, "cuname")    // 2
This example retrieves the "for condition" from an order:
X#
1USE customer NEW
2INDEX ON Customer->Acct TO customer ;
3    FOR Customer->Acct > "AZZZZZ"
4? DBOrderInfo(DBOI_CONDITION,, "customer")
5// Returns: Customer->Acct > "AZZZZZ"
See Also