Brian Dunning's FileMaker Custom Functions

ShuffleValues ( List )

Re-orders a list of values, returning them in a random sequence.

  Average rating: 4.1 (34 votes) Log in to vote

Ray Cologon   Ray Cologon - Show more from this author
NightWing Enterprises
http://www.nightwing.com.au/FileMaker

Share on Facebook Share on Twitter

  Sample input:
John
Paul
George
Ringo
  Sample output:
Ringo
George
John
Paul

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

This is a relatively straightforward recursive function designed to receive a list (values separated by carriage returns) and return it in a random order.

The function includes a closing condition which serves the purpose of ensuring that the returned list does not have an added trailing CR. For consistency with FileMaker 7s other Xvalues functions (all of which add a trailing CR if one isn't already present), this could be left off if desired.

Note that as the returned order is random it is *possible* that the list may be returned in the same order - though the probability of this reduces radically as the number of items on the list increases (eg with a list of only two items the probability that they will be returned with their order unchanged is 0.5, with three items the probability reduces to 0.17 and with four it is approx 0.04)

 

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.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 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: