PA_OrderBy


version 2003


PA_OrderBy (tNum; fNum; oDirection)

Parameter Type Description
tNum short Table number
fNum short Field number
oDirection char Ordering direction

Description

The routine PA_OrderBy sorts (reorders) the records of the current selection of table tNum for the current process using the field fNum . After the sort has been completed, the new first record of the selection becomes the current record.

Set oDirection to any value but 0 to order in an ascending direction.

Set oDirection to 0 to order in a descending direction.

PA_OrderBy

is a quick way to reorder a selection using only one field as criteria.

To reorder the selection using 2 or more fields, you must do so in the following manner:

1/ Tell the API that you want to start a complex sort by calling PA_OpenOrderBy ,
2/ Call PA_AddFieldToOrderBy for every field you want to add as a sort criteria,
3/ Call PA_CloseOrderBy to start sorting.

To dispatch the standard "Order By" 4D dialog, call PA_OrderByDialog .

Examples

(1) Reorder selection of table 2 by field 3, ascending

   PA_OrderBy(2, 3, 1);

(2) Two macros that wrap PA_OrderBy

   #define ORDERBY_ASC(t, f)      PA_OrderBy(t, f, 1)
   #define ORDERBY_DESC(t, f)      PA_OrderBy(t, f, 0) 

See Also

ORDER BY , PA_AddFieldToOrderBy , PA_CloseOrderBy , PA_OpenOrderBy , PA_OrderByDialog .

Error Handling

Use PA_GetLastError to see if an error occurred (bad table number)