Set sort field

Command group Flag affected Reversible Execute on client Platform(s)
Sort fields NO YES NO All

Syntax

Set sort field field-name ([Descending][,Upper case][,Subtotals][,New page])

Options

Descending If specified, data for the field is sorted in descending order
Upper case If specified, data for the field is sorted in a case-insensitive manner, converting data to upper case before sorting
Subtotals If specified, the Subtotal section in a report is printed when the value of the sort field changes
New page Only relevant if you specify the subtotals option. If specified, Omnis starts a new page in a report when the value of the sort field changes

Description

This command specifies a field on which a list or report is to be sorted. The report generator systematically works through the records in the main and connected files and prints them using the report class definition. You can use sort fields to sort the records into a specific index order.

A report can be sorted on up to nine fields: you can specify sort fields in the report class or by using Set sort field. Since sort fields are cumulative, use Clear sort fields first to clear any that already exist.

When a report name is selected, the report class sort fields are used but you can override these sort fields by clearing them and specifying new sort ones with Set sort field. For nine sort fields, you use the Set sort field command nine times in succession. Using this method, however, can be slower than sorting on fields that are already indexed.

You can set the sort fields for lists using Set sort field. The Sort list command sorts the current list in the order specified by the current sort fields. Note that lists have to be explicitly redrawn before you can view the results of a sort.

If used within a reversible block, the sort field setting reverts when the method terminates.

The Descending option sorts the records in descending order. The Upper Case option converts lower case characters to upper case for the purpose of sorting. The Subtotals option causes the Subtotal section in the report to be printed when the value of the sort field changes. Thus, in the above example, when AREA changes, subtotals 1 is printed, when DEPT changes, subtotals 2 is printed, and so on. The New Page option starts a new page when the field value changes.

Example

; Sort the report on fields Surname,Balance
Set report name RCOMMISSION
Clear sort fields
Set sort field fAccounts.Surname
Set sort field fAccounts.Balance
Set report name rMyReport
Send to screen
Print report