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
*/
// ===================================
/* SortCheckBox ( _self )__LITBR____LITBR__by Fabrice Nordmann__LITBR__http://www.1-more-thing.com__LITBR____LITBR__v.2.0 - Mar 2010__LITBR__ - easier to use__LITBR__ - requires FileMaker 9__LITBR__ - has a parameter ( _self ). Simply remove the underscore in your calc : SortCheckBox ( Self )__LITBR__v.1.1 - Dec 2008__LITBR__ - Documentation update__LITBR__ - FileMaker 8 compatibility__LITBR__v.1.0 - Dec 2008__LITBR____LITBR____LITBR__Used in an always evaluating auto-enter, allows to resort the field based on the value list attached to it.__LITBR__The sort will happen only if the field object is formatted as checkboxes. Else the field is left as is.__LITBR____LITBR__Not Recursive__LITBR____LITBR__If you use this as a custom function, don't forget to ensure the calc is evaluated by referencing the field in the calculation.__LITBR____LITBR__ Let ( _trigger = Self ; SortCheckBox ) // requires FileMaker 9, DO NOT USE IN SEPARATION MODEL__LITBR__ or__LITBR__ Let ( _trigger = <<yourFieldNameHere>> ; SortCheckBox ) // you need to adapt for every field, but it's FileMaker 8 and inSeparation compatible__LITBR____LITBR__If you don't use this as a custom function but only as an auto-enter calc, you can paste only this code__LITBR__(requires FileMaker 9 and shouldn't be used in separation model unless you have FileMaker 10 or greater) :__LITBR__============__LITBR__Let ([__LITBR__ _content = Self__LITBR__; _style = FieldStyle ( Get ( FileName ) ; Get ( LayoutName ) ; Get ( ActiveFieldName )) & ¶__LITBR__; _pos = Position ( _style ; "Checkbox " ; 1 ; 1 )__LITBR__; _vl = Case ( _pos ; Middle ( _style ; _pos + 9 ; Position ( _style ; ¶ ; _pos ; 1 ) - _pos - 9 ))__LITBR__];__LITBR__Case ( not IsEmpty ( _vl ) ; FilterValues ( ValueListItems ( Get ( FileName ) ; _vl ) ; _content ) ; _content )__LITBR__)__LITBR__============__LITBR__*/__LITBR____LITBR____LITBR__Let ([__LITBR__ _content = Get ( ActiveFieldContents )__LITBR__; _style = FieldStyle ( Get ( FileName ) ; Get ( LayoutName ) ; Get ( ActiveFieldName )) & ¶__LITBR__; _pos = Position ( _style ; "Checkbox " ; 1 ; 1 )__LITBR__; _vl = Case ( _pos ; Middle ( _style ; _pos + 9 ; Position ( _style ; ¶ ; _pos ; 1 ) - _pos - 9 ))__LITBR__];__LITBR__Case ( not IsEmpty ( _vl ) ; FilterValues ( ValueListItems ( Get ( FileName ) ; _vl ) ; _content ) ; _content )__LITBR__)__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/139__LITBR____LITBR__ Prototype: SortCheckBox( _self )__LITBR__ Function Author: Fabrice (http://www.fmfunctions.com/mid/37)__LITBR__ Last updated: 05 March 2010__LITBR__ Version: 2.0__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.
Comments
18 December 2008
18 December 2008
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 )