Jump to content

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


This topic is 2776 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This topic is 2776 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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