Brian Dunning's FileMaker Custom Functions

FilterPartialValues ( values ; string )

Exclude values that contain string.

  Average rating: 4.0 (21 votes) Log in to vote

Richard Dyce   Richard Dyce - Show more from this author
Dyce & Sons Ltd.
http://dyce.com

Share on Facebook Share on Twitter

  Sample input:
FilterPartialValues ( "Item List¶item_scripting¶User List¶user_scripting¶Prefs" ; "_scripting" )
  Sample output:
item_scripting
user_scripting

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This is simply convenience function, used to search for 'scripting' layouts.
Updated to avoid adding a trailing return

 

Comments

Agnès   Agnès, France
Apr 26, 2016
Hi,

You can also have the same result without recursion ;)

Let ([

L = "Item List¶Item_scripting¶User List¶user_scripting¶Prefs" ;
Keep = "_scripting" ;

R = "#" & Substitute ( L ; [ ¶ ; "¶#" ] ; [ Keep ; Keep & ¶ & Keep ] ) ;
Fb = Substitute ( R ; [ ¶ ; "#¶"] ; [ Keep & "#" ; Keep ] ) & "#"

];
Substitute ( FilterValues ( R ; Fb ) & "[end]" ; [ "#¶" ; "" ] ; [ "¶[end]" ; "" ] ; [ "#" ; "" ] ; [ Keep & "¶" & Keep ; Keep ] )
)

this way is case sensitive ( add upper for no )
 
Richard   Richard, Zuchwil
Apr 26, 2016
Agnès, you're clearly on a roll ;-) Thanks, R
 
Richard   Richard, Zuchwil
Apr 26, 2016
Agnès, where exactly are you adding Upper for case-insensitive? Or is that an exercise for the student? ;-)
 
Richard   Richard, Zuchwil
Apr 26, 2016
Agnès, ahem, sorry, but I'm not sure that the non-recursive works for all the same cases:

Assuming your version is implemented (and I haven't screwed up the implementation):

// FilterPartialValues_NR ( values ; string )

// FilterPartialValues_NR ( values ; string )

Let (
[
R = "#" & Substitute ( values ; [ ¶ ; "¶#" ] ; [ string ; string & ¶ & string ] ) ;
Fb = Substitute (
R ;
[ ¶ ; "#¶"] ;
[ string & "#" ; string ]
) & "#"
];

Substitute (
FilterValues ( R ; Fb ) & "[end]" ;
[ "#¶" ; "" ] ;
[ "¶[end]" ; "" ] ;
[ "#" ; "" ] ;
[ string & "¶" & string ; string ]
)
)


Then,

FilterPartial_NR ( "Item List¶item_scripting¶User List¶user_scripting¶Prefs" ; "script" )

returns:

"item_script¶user_script"

Whereas, the original version:

FilterPartialValues ( "Item List¶item_scripting¶User List¶user_scripting¶Prefs" ; "script" )

returns:

"item_scripting¶user_scripting"

:-(
 
Agnès   Agnès, France
Apr 26, 2016
Oh sorry, I'ts an old calc, and I removed that line, I do not know why she was there...
D = FilterValues ( R ; Substitute ( R ; "#" ; "" ) ) without checking calc !

donc :

Let ([

L = "Item List¶Item_scripting¶User List¶user_scripting¶Prefs" ;
Keep = "_scr" ;

R = "#" & Substitute ( L ; [ ¶ ; "¶#" ] ; [ Keep ; Keep & ¶ & Keep ] ) ;
Fb = Substitute ( R ; [ ¶ ; "#¶"] ; [ Keep & "#" ; Keep ] ) & "#" ;
D = FilterValues ( R ; Substitute ( R ; "#" ; "" ) )
];
Substitute ( FilterValues ( R ; Fb & ¶ & D ) & "[NoValue]" ; [ "#¶" ; "" ] ; [ "¶[NoValue]" ; "" ] ; [ "#" ; "" ] ; [ Keep & "¶" & Keep ; Keep ] /* ; [ "[NoValue]" ; "" ] */ )

it's ok
 
Agnès   Agnès, France
Apr 26, 2016
For Case no sensitive :

Let ([

L = "Item List¶Item_scripting¶User List¶user_scripting¶Prefs" ;
Keep = Upper ( "_Scr" ) ;

R = "#" & Substitute ( Upper ( L ) ; [ ¶ ; "¶#" ] ; [ Keep ; Keep & ¶ & Keep ] ) ;
Fb = Substitute ( R ; [ ¶ ; "#¶"] ; [ Keep & "#" ; Keep ] ) & "#" ;
D = FilterValues ( R ; Substitute ( R ; "#" ; "" ) ) ;
Result = Substitute ( FilterValues ( R ; Fb & ¶ & D ) ; [ "#¶" ; "" ] ; [ "#" ; "" ] ; [ Keep & "¶" & Keep ; Keep ] )

];
Substitute ( FilterValues ( L ; Result ) & "[NoValue]" ; [ "¶[NoValue]" ; "" ] )
)

but the calc is less pretty ;)
 
Eric   Eric, SJSU
Apr 29, 2016
CF Description says "Exclude values that contain string."
Would a description such as "Search only values containing string" not be more appropriate ?
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: