Xbasic

A5_SORT_EXPRESSION Function

Syntax

Order_Expression as C = a5_sort_expression(P sort_data )

Arguments

Order_Expression

An order expression suitable to use with query.order.

sort_data

The a_sort[] array has three properties that must be set for each field in the order expression.

Property

Description

.expression

The name of a field or an expression involving one or more fields.

.type

The data type of the field.

.direction

"A" = Ascending, "D" = Descending

Description

Generates a sort expression from an input array of sort keys

Discussion

The A5_SORT_EXPRESSION() function builds a order expression for a table. The fields may be of any type.

Example

dim a_sort[3] as P
 a_sort[1].expression = "salary" 
 a_sort[1].type = "n" 
 a_sort[1].direction = "D" 

 ? a5_sort_expression(a_sort) 
 = "invert(salary)" 

 a_sort[2].expression = "lastname" 
 a_sort[2].type = "c" 
 a_sort[2].direction = "a" 

 ? a5_sort_expression(a_sort) 
 = "invert( str(salary,19,5) )+lastname"

See Also