Brian Dunning's FileMaker Custom Functions

SwapValues ( list ; value1 ; value2 )

Swaps two items in a valuelist

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

Theo Ros   Theo Ros - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
SwapValues ( "John¶Paul¶George¶Ringo" ; 1 ; 3 )
  Sample output:

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

Swaps two items in a valuelist

In: list - the list of Return delimited values
value1 - the number of the first value to swap
value2 - the number of the second value to swap

If the given value numbers are outside the total range of the list, no action is taken and the list is returned unchanged. If value1 and value2 are equal numbers, again nothing is done to the original list. When the function does swap values, a list is returned without leading or trailing returns.

Return type: Text
Syntax: SwapValues ( list ; value1 ; value2 )

SwapValues ( "John¶Paul¶George¶Ringo" ; 1 ; 3 )
returns "George¶Paul¶John¶Ringo"

Note: for best results, trim empty returns from the list before calling this function by using LeftWords ( list ; 999999999 )



Log in to post comments.


Note: these functions are not guaranteed or supported by 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 16 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: