Software Venture Consulting

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

Free Web Tools
Free FileMaker Tools

Personal Pages

Shopping Cart
Shopping Cart


Free Newsletter


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

ALoopingDemo ( AnyText )

Rate this function:  

  Average rating: 4.6  (25 votes)
  Discuss this Custom Function

Doug Staubach, FileMaker Poweruser

This demo shows how to create a conditional loop within a custom function (similar to Do-Loop; Do-While and For-Next).

Sample Input:
Sample Output:

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



1. FileMaker custom functions do not support looping statements (Do, While, For-Next) or line-jumping (GoTo).

2. FileMaker custom functions do not support the use of "optional parameters" (parameters that do not have to be included with the function call), which might help to simulate some of the above functions.

The code demonstrated in this function shows how to create a conditional loop using Case(), Let(), Recursion, and a local script variable ("$", not "$$").

Using this technique, you can create a loop with the ability to perform different actions at each "step" in the loop (1, 2, 3, etc.).


1. Tested using FileMaker 13 - should work on v12 also.

2. Does not have any dependencies on any other custom functions.

3. Does not require a secondary function to keep track of counters.


1. I did not invent this technique. It has been in existence for a long time (if you know the original author, please let me know so I can give them credit). I am just showing a simple example for people who want to include some sort of looping mechanism inside of a FileMaker custom function, and haven't tried this method before.

2. FileMaker has a limit of 10,000 nested recursions per function call. Therefore, it makes sense to use this technique for an internal loop counter, but it is not good to use this technique for looping through large data sets (in that case, you might want to check out the looping capabilities of FileMaker scripts, which have fewer limits).

3. You will need a copy of "FileMaker Advanced" to *create* a custom function, but functions that have been created with "FileMaker Advanced" and saved into a database, can be freely used by "FileMaker Pro" clients who access that database.

If you like this function, please rate it (scroll up, under the function name), or leave a comment below.

Doug Staubach

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

This is my Custom Function and I want to edit it


5 most recent comments | Show all 7 comments

Boy, i use and studied many CF but this is one CF i cannot see ANYTHING from its example! Why and how got numbers 1-9?? sounds really neat though!!

jLT StructuresFromSilence, Kendv,IN USA
March 27, 2015 3:38pm

Hi all:

Unix - yes, you can start the loop midway if you set the $LoopCount to 5 before you call the function.

Brian - thank you very much, glad you found it useful!

jLT - The numbers 1-9 come from the middle loop (AnyText = AnyText & "." & $LoopCount)

Best wishes,

Doug Staubach, Denver, Colorado, USA
March 27, 2015 10:45pm

Extremely useful function! Thank you very much for taking the time to explain.

This is a template function that should deserve a special place in the function list, because it is really the starting point for many other CF's.

Hans Erik Hazelhorst, Utrecht, Netherlands
June 27, 2015 3:02pm

Hi Hans:

Thank you; I'm glad that you found it so useful!

Doug Staubach, Denver, CO USA
November 12, 2015 1:49pm

Above solution has a disadvantage, since it forces the core algorithm to be done in the loop to be defined twice. Following solution avoids that:

Case (
not $ix ; Let ( [ $OtherVariable = "" ; $ix = from ] ; MyLoop ( from ; to ; AnyText ) ) ;
$ix ≤ to ; Let ( [ <do something with AnyText> ; $ix = $ix + 1 ] ; MyLoop ( from ; to ; AnyText ) ) ;
$ix > to ; Let ( [ $OtherVariable = "" ; $ix = "" ] ; AnyText )

If you look at above FM script with a monofont, you can see better what is going on. A simple example not needing $OtherVariable (similar
to what is done above) would be:

Case (
not $ix ; Let ( [ $ix = from ] ; MyLoop ( from ; to ; AnyText ) ) ;
$ix ≤ to ; Let ( [ AnyText = AnyText & "." & $ix ; $ix = $ix + 1 ] ; MyLoop ( from ; to ; AnyText ) ) ;
$ix > to ; Let ( [ $ix = "" ] ; AnyText )

Again look at it with a monofont to understand better. Hope this helps.

Andreas Fischlin, Zurich, Switzerland
February 23, 2018 6:36am

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

Your Name:
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 1 + 7 =
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. SortList ( theList )
  (Sat, Jun 23, 8:45am)
2. HexUUIDToNum_cf (_uuid)
  (Sat, Jun 16, 1:55pm)
3. httpResponseCode ( responseHeaders )
  (Tue, Jun 12, 10:40pm)
4. FindDuplicateCharacters ( string )
  (Fri, Jun 08, 5:01pm)
5. FieldRepetitionLast ( field ; maxRepetition )
  (Wed, Jun 06, 6:05pm)
6. CountModifiedRecords ( NameTimestampField ; StartTimestamp ; EndTimestamp )
  (Mon, May 28, 8:23am)
7. JSONArrayLength ( JSONArrayStr )
  (Fri, May 25, 7:46am)
8. interpolation (y1; y2; y3; x1; x2; x3; x1y1; x2y1; x1y2; x2y2; rnd)
  (Sat, May 19, 3:55am)

RSS Feed of Custom Functions