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.

Help creating a recursive function to return a list of tables that contain a text string

Featured Replies

So I'm pretty new to writing recursive functions and I want to create a function that will contain a list of tables in my solution that contain a specific text phrase.  I can use PatternCount and the Get ( TableNames ) function to see that there are 6 tables in my solution that match my search criteria but from there I get stuck.

The calculation

PatternCount ( Get ( TableNames ) ; "myFile" ) ; "myTextPhrase" )

 Returns a value of '6'.

 

How would I write a calculation to return the values of the tables that match the text phrase?

 

Edited by James Gill

If you're doing this in a script, why not let the script handle it using a loop, instead of splitting the logic off to a custom function?

  • Author

I could definitely do it in a script but for this I'm trying to use it in an un-stored calculation field

 

Edit: Realized I specifically said script in my description.  Removed it to better describe what I want to do

Edited by James Gill

You could do it this way:

ValuesContaining ( listOfValues ; searchString ) =
Let ( [
value = LeftValues ( listOfValues ; 1 ) ;
nextList = RightValues ( listOfValues ; ValueCount ( listOfValues ) - 1 )
] ;
Case ( PatternCount ( value ; searchString ) ; value )
&
Case ( 
PatternCount ( nextList ; searchString ) ;
ValuesContaining ( nextList ; searchString )
)
)

then call this function as :

   ValuesContaining ( TableNames ( Get (FileName) ) ; "myTextPhrase" )

Using the TableNames() function directly in the custom function is less convenient, because it doesn't change between iterations - unlike the listOfValues parameter above, that dwindles by one every time. Besides, having a generic custom function that can handle any list of values is way cooler.

I have to ask...why are you doing this?

  • Author

I have to ask...why are you doing this?

​I needed a way to include only tables occurrences with a specific naming convention to use in a 3rd party solution (CCPivot).

  • Author

God point.  In this I was just trying to use a technique that was close to the original method that was being used.  As usual and especially with Filemaker, there is usually more than 1 way skin a cat.

Some response would be nice...

  • Author

Some response would be nice...

​Oh, weird.  I thought I replied last night but apparently my reply got swallowed by the internet troll.  Yes, the technique worked perfectly for what I needed it for.  Is there a guide somewhere on how recursion words in Filemaker and what functions will work with recursion?  I never would have guessed that a native Filemaker function didn't support recursion...

Something definitely is not working right with this new forum. As you can see from the attached screenshot, you have replied 3 hours ago - but I am still listed as the last poster.

bad.thumb.png.7d1807f6dbc103fe098a64c611

​Is there a guide somewhere on how recursion words in Filemaker and what functions will work with recursion?

​ Only custom functions can be recursive (i.e. call themselves). You can use any function inside a custom function, including itself (hence recursion).

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.