Report comment

I'm not the first person to do this kind of loop iteration. FileMakerStandards.org has a page about it (http://filemakerstandards.org/display/bp/Iterators); I don't think Matt is the first person to do this, either.

There are other custom functions for this, too; but I don't use them, even when I'm not trying to minimize dependencies for ModularFileMaker.org. Custom functions are less transparent about what their doing, which will slow down future maintenance developers who may not be as familiar with the functions I like to use as I am.

One possible issue with your particular function is that the iterator variable is hard-coded in the function, so it wont work with nested For loops, and locks developers into your choice of iterator variable. (I'm less concerned about the latter issue; if a developer is adopting your functions, there's a good chance they adopt your conventions, too.) Other functions exist that deal with this by accepting a parameter for the iterator variable name, but this means they use Evaluate ( Let ( ... ) ) to set the variable, which is relatively slow.

I use a Text Expander snippet instead. Recent versions of Text Expander include a feature for 'fill-in' snippets, so when I trigger that snippet, I only have to type the iterator variable name and the max value once, and the snippet repeats those where they need to be in the rest of the calculation. It also means I don't have to remember to install a custom function before using the technique in a new file (with the caveat that I have to be on my own computer.)

I actually resisted the technique when I first saw it. I figured that putting all the functionality in a single calculation obscures what it's doing more than splitting it out into separate script steps. I'm still on the fence about that. Using a For loop template script snippet in Clip Manager would be nearly as fast as the Text Expander snippet.