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
n/a
n/a

Share on Facebook Share on Twitter

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

  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 )

 

Comments

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.