Brian Dunning's FileMaker Custom Functions

MoveItem ( myList ; n1 ; n2 )

Moves item at position n1 to position after orignal n2

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

Bruce Robertson   Bruce Robertson - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
MoveItem("1¶2¶3¶4¶5"; 2; 4)
MoveItem("1¶2¶3¶4¶5"; 3; 1)
  Sample output:
Result: "1¶3¶4¶2¶5"
Result: "1¶3¶2¶4¶5"

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

Moves item at position n1 to position after original n2. I'm using this in scripted drag and drop list re-ordering.

See example file here:

http://concise-design.com/downloads/dropdemo.zip

 

Comments

JJackson   JJackson, Santa Rosa, CA
Nov 13, 2013
Here is a fix for moving something to the front of a list:

Change the line

n2 < 1; myList;

to read

n2 = 0; V1 & "¶" & L1;
n2 < 1; myList;

Now,
MoveItem("1¶2¶3¶4¶5"; 2; 0) Result: "2¶1¶3¶4¶5"

A similar change could be made to move something to the end. Passing in -1 for n2?
 

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: