Function overview
Prototype
list.filter (
listValues; test; dataType )
Parameters
listValues A list of values to be processed
test A test to be evaluated. All strings should be quoted
dataType Your value data type (one of number, text or date)
Description
Tags:
Recursive List Filter
Iterates over each value in the input list passing them to the test to be evaluated - the value is available as the keyword "value". If the evaluated test returns true, the current value from is returned to the result list.
Examples
Sample input
list.filter( "Bob¶Jane¶Martha¶Brian¶Jose" ; "Left( value ; 1 ) = \"B\" OR Left( value ; 1 ) = \"J\"" ; "text" )
Sample output
Bob¶Jane¶Brian¶Jose
Function code
Let([
valCount = ValueCount(listValues);
plainVal = LeftValues(listValues;1);
plainVal = Left( plainVal ; Length(plainVal) - 1 );
value = If( not IsEmpty(plainVal) ;
Case(
dataType = "int" or dataType = "number" ; GetAsNumber(plainVal) ;
dataType = "date" or dataType = "time" or dataType = "timestamp" ; GetAsTimestamp(plainVal);
dataType = "string" or dataType = "text" or dataType = "" ; Quote(plainVal)
)
);
curTest = Substitute( test ; "value" ; value );
result = If( IsEmpty(value) ; 0 ; Evaluate(curTest) )
];
If( result ; plainVal & If( valCount > 0 ; ¶ ) )
& If( valCount > 0 ; list.filter( MiddleValues( listValues ; 2 ; valCount - 1 ) ; test ; dataType ) )
)
// ===================================
/*
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/86
Prototype: list.filter( listValues; test; dataType )
Function Author: Genx (http://www.fmfunctions.com/mid/29)
Last updated: 01 February 2009
Version: 1.4
*/
// ===================================
Let([__LITBR__ valCount = ValueCount(listValues);__LITBR__ plainVal = LeftValues(listValues;1);__LITBR__ plainVal = Left( plainVal ; Length(plainVal) - 1 );__LITBR__ value = If( not IsEmpty(plainVal) ; __LITBR__ Case(__LITBR__ dataType = "int" or dataType = "number" ; GetAsNumber(plainVal) ;__LITBR__ dataType = "date" or dataType = "time" or dataType = "timestamp" ; GetAsTimestamp(plainVal);__LITBR__ dataType = "string" or dataType = "text" or dataType = "" ; Quote(plainVal)__LITBR__ )__LITBR__ );__LITBR__ curTest = Substitute( test ; "value" ; value );__LITBR__ result = If( IsEmpty(value) ; 0 ; Evaluate(curTest) )__LITBR__];__LITBR__ If( result ; plainVal & If( valCount > 0 ; ¶ ) )__LITBR__ & If( valCount > 0 ; list.filter( MiddleValues( listValues ; 2 ; valCount - 1 ) ; test ; dataType ) )__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/86__LITBR____LITBR__ Prototype: list.filter( listValues; test; dataType )__LITBR__ Function Author: Genx (http://www.fmfunctions.com/mid/29)__LITBR__ Last updated: 01 February 2009__LITBR__ Version: 1.4__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.