Show/Hide Toolbars

XSharp

NoteThis command is defined in a header file and will be preprocessed by the X# preprocessor to a function call. If you disable the standard header (-nostddefs) files then this command will not be available. If you tell the compiler to use a different standard header file (-stddef ) then this command may also be not available

Purpose

Set the controlling order for the current work area.

Syntax

SET ORDER TO [<nPosition> | TAG <xcOrder> [IN <xcIndexFile>]]

Arguments

<nPosition> | TAG <xcOrder>
The name of the new controlling order or a number representing its position in the order list.  Using the order name is the preferred method since the position may be difficult to determine using multiple-order indexes.  Specifying a value of 0 has the special effect of returning the database file to its natural order.  Specifying an invalid value will raise a runtime error.
 
Note:  The syntax of this command differs from other Xbase dialects where the TAG keyword is optional.

 

IN <xcIndexFile>The name of an index file, including an optional drive and directory (no extension should be specified).  Use this argument to remove ambiguity when there are two or more orders with the same name in different index files.
 
If <xcIndexFile> is not open by the current process in the current work area, a runtime error is raised.
 
SET ORDER TO with no arguments is the same as SET ORDER TO 0.

Description

The controlling order determines the order in which the database file is processed.  No matter which order is currently controlling the logical order of the database file, all orders in the order list are properly updated when records are added or updated.  This is true even if you SET ORDER TO 0.  Changing the controlling order does not move the record pointer.

 

Before using this command, use SET INDEX or DBSetIndex() to add orders from an index file to the order list.

SET ORDER is functionally equivalent to DBSetOrder().  

Examples

The following example illustrates a typical use of SET ORDER to select between several orders:

 

USE customer NEW
INDEX ON Lastname TO names
INDEX ON City + State TO region
SET INDEX TO names, region
//
SET ORDER TO TAG "Region"
? DBOrderInfo(DBOI_EXPRESSION)
// Result:  City + State
 
SET ORDER TO 0
? DBOrderInfo(DBOI_EXPRESSION)
// Result:  NULL_STRING
 
SET ORDER TO TAG "Names"
? DBOrderInfo(DBOI_EXPRESSION)
// Result:  Lastname

Assembly

XSharp.RT.DLL

See Also

DbOrderInfo(), DbSeek(),DbSetIndex(), DbSetOrder(), INDEX, SEEK, SET INDEX, USE