Brian Dunning's FileMaker Custom Functions

PickAPart__cf ( _text ; _partNumber )

Will return the specified _partNumber within delimited _text

  Average rating: 4.2 (35 votes) Log in to vote

Matthew Leering   Matthew Leering
CoreSolutions Software Inc.
http://coresolutions.ca

Share on Facebook Share on Twitter

  Sample input:
PickAPart__cf ( "A|B|C|D|E|F|G|H" ; 5 )
  Sample output:
E

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

To search a string of text with the delimiter defined below, and return only a particular part number from that text

 

Comments

Tim   Tim, Scotland
Oct 2, 2013
Looks over complicated

how about

getvalue( substitute( _text;"|";"¶");_partNumber)

extending that you could even included a parameter for the delimiter
 
Matthew Leering   Matthew Leering, Canada
Oct 3, 2013
Your solution is excellent Tim!
It's very easy to understand exactly what it's doing, and is efficient also.
The only drawback I can see to it is that it won't support parts that have hard-returns.
 
William   William, Seattle
Oct 3, 2013
... and yours will not work if the pipe is part of the part number :-))
 
Matthew Leering   Matthew Leering, Canada
Oct 3, 2013
Touché
Of course, this custom function does let you swap out the delimiter for any other character or set of characters you deem fit.
 
Tim   Tim, Scotland
Oct 4, 2013
Ok, a solution


PickAPart__cf ( _text ; _partNumber ; delimiter)

let( _useText=case( delimiter="¶"; _text; substitute( _text;"¶"; "x§§x§§x");


substitute( getvalue( substitute( _useText ; delimiter ;"¶");_partNumber); "§§x§§";"¶")
)
 

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.

Under construction. Email me your wish list for improvements.