Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

joinRepeatingVariableFast ( variableName ; delimiter ; startIndex ; endIndex )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.4  (29 votes)
  Discuss this Custom Function

Sam Barnum, 360Works
http://www.360works.com

Join / concatenate a large repeating variable / array using a delimiter character

Sample Input:
$$foo[1] = "FOO"
$$foo[2] = "BAR"
$$foo[3] = "BAZ"
joinRepeatingVariable("$$foo" ; ", " ; "1" ; "3")
Sample Output:
FOO, BAR, BAZ


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

Uses a recursive "divide and conquer" approach to concatenating a large array of values, yielding better performance than simply iterating over the array appending each item to a large string.

Unlike the version at http://www.briandunning.com/cf/1285, this focuses primarily on performance, and does not stop when it reaches the end of the array (all parameters are required).

There is a commented line which clears out the array contents as they are appended, saving memory at a small speed penalty.

The performance increase is achieved by avoiding creating/appending to very large strings. Instead, most of the concatenation operations happen on smaller strings, the smaller bits being built into larger strings at the end.

Benchmarks from a 10,000 repetition variable, each entry 100 characters long:

* Looping append Script, simple: 13,505ms
* joinRepeatingVariable Recursive Concatenation CF: 6,904ms
* joinRepeatingVariableFast CF with clearing array: 2,960ms
* joinRepeatingVariableFast CS without clearing array: 2,330ms
* Looping "divide and conquer" script: 1,930ms

For 20,000 repetitions:
* Looping append Script, simple: 79,026ms
* joinRepeatingVariable Recursive Concatenation CF: ? (too many recursions)
* joinRepeatingVariableFast CF with clearing array: 5,960ms
* joinRepeatingVariableFast CS without clearing array: 4,626ms
* Looping "divide and conquer" script: 3,979ms

For 40,000 repetitions
* Looping append Script, simple: 523,167ms
* joinRepeatingVariable Recursive Concatenation CF: ? (too many recursions)
* joinRepeatingVariableFast CF with clearing array: ? (too many recursions)
* joinRepeatingVariableFast CS without clearing array: (too many recursions)
* Looping "divide and conquer" script: 8,228ms

Note that these techniques fall apart once the arrays get too large, because of the stack limit. You would want to switch to a scripted approach to get around this, but use a similar mechanism where you concatenate the smallest strings first, then join them into larger and larger batches.

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

Are you sure you're function is faster than the one you reference? Have you tested it and demonstrated it? Can you post a demo file somewhere? As far as I can tell, both algorithms have to perform the same O(N) string concatenations, and they even ultimately do those concatenations in the same order. Am I missing something?

Jeremy, NC
November 19, 2012 12:11pm

Thanks Jeremy, I posted some benchmarks. During testing, I hit the "max stack" issue with FileMaker custom functions. I'd recommend writing a looping script if this becomes an issue.

Sam Barnum, San Francisco
November 20, 2012 12:11am

Doesn't work as written (won't compile successfully in custom function editor). Example doesn't make sense. It calls a function JoinArray which is undefined. Example contains no index values. An example file would really be helpful because it is hard to tell what this is supposed to do.

Bruce Robertson, Redmond
November 21, 2012 4:01pm

Thanks Bruce, I had changed the name of the function, but forgot to update the recursive calls in the function itself

Sam Barnum, San Francisco
November 21, 2012 4:40pm

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 5 + 5 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions