PA_OpenOrderBy

4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next

version 2003


PA_OpenOrderBy (tNum) PA_OrderByRef

ParameterTypeDescription
tNumshortTable number

Description

The routine PA_OpenOrderBy tells the API to prepare an Order By sequence for the current selection of table tNum in the current process. After calling this routine, you will add sort criteria (fields and their ordering order) using PA_AddFieldToOrderBy and then start the sorting by calling PA_CloseOrderBy.

tNum is the table which selection must by reordered. PA_AddFieldToSelection may include related fields, as in the ORDER BY command.

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

Examples

(1) We want to sort this table(N°1) by Command_Theme and Command_Name, ascending.

   // Prepare to sort Table N°1 ([Commands])
      ref = PA_OpenOrderBy(1);
   // Add [Commands]Theme_Name field, ascending.
      PA_AddFieldToOrderBy(ref, 1, 3, 1);
   // Add [Commands]Command_Name field, ascending.
      PA_AddFieldToOrderBy(ref, 1, 2, 1);
   // Sort
      PA_CloseOrderBy(ref);
   // Error check is done with PA_GetLastError();

(2) Our structure is now this one, which is a bit more efficient :

[Commands] is table 1 and [Themes] is table 2. We want to sort [Commands] by Theme_Nams and Command_Name.

   // Prepare to sort
      ref = PA_OpenOrderBy(1);
   // Add [Themes]Theme_Name field, ascending.
      PA_AddFieldToOrderBy(ref, 2, 2, 1);
   // Add [Commands]Command_Name, ascending.
      PA_AddFieldToOrderBy(ref, 1, 2, 1);
   // Sort
      PA_CloseOrderBy(ref);
   // Error check is done with PA_GetLastError();

See Also

PA_AddFieldToOrderBy, PA_CloseOrderBy, PA_OrderBy, PA_OrderByDialog.

Error Handling

PA_GetLastError() keeps the last error that occurred before calling the routine. If the table number is invalid, it is after the call to PA_CloseOrderBy that PA_GetLastError will return an error.


4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next