forked from DonovanChan/fmfunctions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFieldSortValue.calc
36 lines (31 loc) · 1.14 KB
/
FieldSortValue.calc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Let([
_sort_field = sortFieldName ;
_sort_field_descending = sortFieldDescending ;
_sort_descending = sortDescending ;
_field_type = MiddleWords ( FieldType ( Get ( FileName ) ; _sort_field ) ; 2 ; 1 )
];
Case (
//-- Sort settings don't match, Show nothing
GetAsBoolean ( _sort_field_descending ) ≠ GetAsBoolean ( _sort_descending ) ; "" ;
//-- Text field, Show text
_field_type = "text" ; GetField ( _sort_field ) ;
//-- Else, format for date or number
Let([
nF = GetField ( _sort_field ) ;
nT = Int (nF) ;
nM = Mod ( nF ; 1) ;
nX = If (nM ; nM ; ".0" )
];
Right ( "0000000000000000" & nT ; 16 ) & nX
)
)
)
/* __________________________________________________
NAME: FieldSortValue ( sortFieldName ; sortFieldDescending ; sortDescending )
PURPOSE: Returns value from current record if sort sort direction matches direction for this calc. Results are formatted to preserve sort order of non-text values while sorting by text field.
EXAMPLES:
HISTORY:
Based on demo by Ray Cologon at nightwing.com.au
Created: 2010-07-19 15:41 PT - Donovan Chandler
Modified: 2013-02-19 13:43 PT - Donovan Chandler : renamed; formatting.
*/