SortCheckBox ( )

Function stats

Average user rating
37
139
9999
Support
FileMaker 9.0 +
Date posted
13 December 2008
Last updated
05 March 2010
Version
Recursive function
No

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

SortCheckBox  ( _self )


Parameters

_self  Just remove the underscore in your calc


Description

Tags:  Value List   sort   List   Layout   interface   Auto Enter  

Used in an always evaluating auto-enter, allows to resort the field based on the value list attached to it.
The sort will happen only if the field object is formatted as checkboxes. Else the field is left as is.

Not Recursive

Examples

Sample input

a checkbox formated field with values {one;two;three;four;five}


Sample output

the field is always sorted like the valuelist, even if items were checked in a different order.

 

Function code

/* SortCheckBox ( _self )

by Fabrice Nordmann
http://www.1-more-thing.com

v.2.0 - Mar 2010
- easier to use
- requires FileMaker 9
- has a parameter ( _self ). Simply remove the underscore in your calc : SortCheckBox ( Self )
v.1.1 - Dec 2008
- Documentation update
- FileMaker 8 compatibility
v.1.0 - Dec 2008


Used in an always evaluating auto-enter, allows to resort the field based on the value list attached to it.
The sort will happen only if the field object is formatted as checkboxes. Else the field is left as is.

Not Recursive

If you use this as a custom function, don't forget to ensure the calc is evaluated by referencing the field in the calculation.

Let ( _trigger = Self ; SortCheckBox ) // requires FileMaker 9, DO NOT USE IN SEPARATION MODEL
or
Let ( _trigger = <<yourFieldNameHere>> ; SortCheckBox ) // you need to adapt for every field, but it's FileMaker 8 and inSeparation compatible

If you don't use this as a custom function but only as an auto-enter calc, you can paste only this code
(requires FileMaker 9 and shouldn't be used in separation model unless you have FileMaker 10 or greater) :
============
Let ([
_content = Self
; _style = FieldStyle ( Get ( FileName ) ; Get ( LayoutName ) ; Get ( ActiveFieldName )) & ¶
; _pos = Position ( _style ; "Checkbox " ; 1 ; 1 )
; _vl = Case ( _pos ; Middle ( _style ; _pos + 9 ; Position ( _style ; ¶ ; _pos ; 1 ) - _pos - 9 ))
];
Case ( not IsEmpty ( _vl ) ; FilterValues ( ValueListItems ( Get ( FileName ) ; _vl ) ; _content ) ; _content )
)
============
*/


Let ([
_content = Get ( ActiveFieldContents )
; _style = FieldStyle ( Get ( FileName ) ; Get ( LayoutName ) ; Get ( ActiveFieldName )) & ¶
; _pos = Position ( _style ; "Checkbox " ; 1 ; 1 )
; _vl = Case ( _pos ; Middle ( _style ; _pos + 9 ; Position ( _style ; ¶ ; _pos ; 1 ) - _pos - 9 ))
];
Case ( not IsEmpty ( _vl ) ; FilterValues ( ValueListItems ( Get ( FileName ) ; _vl ) ; _content ) ; _content )
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/139

    Prototype: SortCheckBox( _self )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 05 March 2010
    Version: 2.0

*/
// ===================================

 

Comments

Genx
18 December 2008



You use self here - shouldn't this be FileMaker 9+ ?
  General comment
Fabrice
18 December 2008



No I don't ;) - I would if it was possible to use Self in a CF.
Self is only in the comment, to give an example of an implementation in an auto enter calc. The function itself uses Get ( ActiveFieldContents ).
Actually, I was hesitating between writing this function without parameters or with ( field ; layout ), so you don't have to remember to trigger the calc with a reference to the field (self). Do you have an input ?
(Edited by Fabrice on 18/12/08 )
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)