Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Infinite series/loops in calculations

Featured Replies

For me, this probably applies more to custom functions and using calculations to set fields or variables in scripts (rather than calculation fields). I'm not sure if this was the right place to post this.

Anyway, I was wondering if there's anyway to have an infinite series in a calculation. I seem to have this issue all the time. Here's an example:

I wanted a calculation that would remove all text between hyphens, including the hyphens, when the text in between the hyphens is less than 50 words, and to separate the remaining text with line breaks. Using my custom function btwn, I have a script write this out, all the way until 250, because I don't foresee ever having more than 250 hyphens in the text to which this would be applied (though sometimes I have to have scripts write out calculations like this, much further):P

If (WordCount (btwn (text ; "-" ; 1 ; "-" ; 1))>49 ; btwn (text ; "-" ; 1 ; "-" ; 1) & ¶) &If (WordCount (btwn (text ; "-" ; 2 ; "-" ; 1))>49 ; btwn (text ; "-" ; 2 ; "-" ; 1)& ¶) &If (WordCount (btwn (text ; "-" ; 3 ; "-" ; 1))>49 ; btwn (text ; "-" ; 3 ; "-" ; 1) & ¶) &If (WordCount (btwn (text ; "-" ; 4 ; "-" ; 1))>49 ; btwn (text ; "-" ; 4 ; "-" ; 1)& ¶) &If (WordCount (btwn (text ; "-" ; 5 ; "-" ; 1))>49 ; btwn (text ; "-" ; 5 ; "-" ; 1)& ¶) &If (WordCount (btwn (text ; "-" ; 6 ; "-" ; 1))>49 ; btwn (text ; "-" ; 6 ; "-" ; 1)& ¶) &If (WordCount (btwn (text ; "-" ; 7 ; "-" ; 1))>49 ; btwn (text ; "-" ; 7 ; "-" ; 1))...

I'm wondering if there's a better way to do something like this. It also seems, that when I do things like this, it takes longer than it should for filemaker to calculate it. If I put something like this in a script that will be used 200 times/day, and it takes 2 seconds to calculate, that's almost a loss of one work-week per year, spent waiting for this calculate.

I've already looked at these posts, but they didn't seem to offer a solution:

http://www.fmforums.com/forum/showtopic.php?tid/195649/

http://fmforums.com/forum/showtopic.php?tid/183426/

Thanks in advance!

Do you know how to write a recursive custom function?

  • Author

I do not. Do you have any links that explain it?

Well, I did on another forum but apparently I am no longer a searchable term over there...

Anyway, a recursive custom function calls itself. Here's a rather primitive example that returns a list of words shorter than 5 characters in given text:

ShortWords ( text )


Let ( [

word = LeftWords ( text ; 1 ) ;

countWords = WordCount ( text )

] ;

Case ( Length ( word ) < 5 ; word & ¶ )

&

Case ( 

countWords > 1 ; 

ShortWords ( RightWords ( text ; countWords - 1 ) )

)

)

You can watch a video on recursive functions here (look for "GetNthRecord Recursion"):P

http://www.itslaves.com/web/guest/filemaker-pro-10-advanced

And here's an article that discusses recursive custom functions:

http://www.informit.com/articles/article.aspx?p=1013850

You'll also find it discussed numerous times if you search FMForums.

The best explanation of recursive functions is here:

http://fmforums.com/forum/showtopic.php?tid/217720

Well played. :P

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.