Brian Dunning's FileMaker Custom Functions

RemoveValue ( theList ; value )

Removes the first value from a paragraph delimited list but leaves all other duplicate values in the list.

  Average rating: 4.3 (36 votes) Log in to vote

Vaughan Bromfield   Vaughan Bromfield

Share on Facebook Share on Twitter

  Sample input:
RemoveValue("a¶b¶a¶c¶b¶c" ; "b" )
  Sample output:
a¶a¶c¶b¶c

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

RemoveValue( theList ; value )
by Vaughan Bromfield

Removes the first value from a paragraph delimited list but leaves all other duplicate values in the list. If the value is not in the list, the list is returned without modification.

Let(

[
newlist = "¶" & Substitute( theList ; "¶" ; "¶¶" ) & "¶" ;
pos = Position( newList ; "¶" & value & "¶" ; 1 ; 1 ) ;
pre = Left( newList ; pos - 1 ) ;
post = Right( newList ; Length( newList ) - ( pos + Length( value ) + 1 ) )
] ;

Case(

IsEmpty( theList ) ; "" ;

pos = 0 ; theList ;

Middle( Substitute( pre & post ; "¶¶" ; "¶" ) ; 2 ; Length( Substitute( pre & post ; "¶¶" ; "¶" ) ) - 2 )

)

)

 

Comments

Mauricio Rodriguez   Mauricio Rodriguez, Villa de Leyva
May 2, 2016
Hello,

Could this be modified to do this:

Input: "1¶1¶2¶2¶1¶2"
Output 1¶2¶1¶2

??


I'm trying to do this but I'm stomped...
 
Vaughan Bromfield   Vaughan Bromfield
May 2, 2016
What are you removing from the first list to get the output?

RemoveValue( "1¶1¶2¶2¶1¶2" ; ? ) = "1¶2¶1¶2"
 

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.