
A simple example of how this can be useful is in a Task Management system where you want a portal in the project detail layout which shows only open task records. If true, the record will appear, if false, the record will not appear. The calculation entered will be evaluated as true or false for each related record that would normally appear in the portal. When selecting the check box to “Filter portal records” or clicking the “Specify…” button, we are presented with the standard calculation window. Step Three – Set the Portal Filter CalculationįileMaker introduced a new feature in FileMaker 11 which allows us to specify a calculation to filter the records that appear in a portal. If this evaluates to true, and there are still words left in needle ( WordCount ( needles ) < 2 evaluates to false), then we make the recursive call with the remaining words in needles, thus bringing us closer to our second base condition. The second defining condition exists when we find a match Left ( word Length ( needle ) ) = needle, which tells us that the first letters in the word we are searching are the same as the the search criteria.The second base condition is when both Left ( word Length ( needle ) ) = needle and WordCount ( needles ) WordCount ( haystack ).Which tells us that we have reached the last word in haystack, and did not find a match, so we return false. The first base condition is start > WordCount ( haystack ).It will loop through each word in haystack for each word in needles. Our function, FindWordPartsInText, is somewhat complex in that it has double recursion. The defining condition must always lead to the base condition eventually in order to avoid infinite recursion. Defining condition that breaks down the complex problem into simpler problems, then calls itself with simpler values leading it closer to the base condition.A base condition that returns a simple value and does not call itself.There are two main features that are necessary for an effective recursive function:
This is done recursively by calling the function within itself.Ī recursive function is a function that calls itself in order to iterate or loop through a problem. If we reach the last word in needle and find a match, then we return 1 or true. If a match is not found and we reach the end of the haystack, we return 0 or false. Once a match is found, we move on to the next word in needle. If that match fails, we move on to the next word in haystack. In short, we start by comparing the first word in the needle with the first characters in the first word in haystack. If you are curious to know just how this function works, read on… Function Details If you give the function a different name, you will need to change the two calls to that function in the function text above. Don’t forget to add the three parameters listed above in the order listed and name the function FindWordPartsInText. Left ( word Length ( needle ) ) = needle įindWordPartsInText ( RightWords ( needles WordCount ( needles ) - 1 ) haystack 1 )įindWordPartsInText ( needles haystack start + 1 )Īt this point, you can copy and paste the above function and skip to step three if you wish. The function, which I am calling FindWordPartsInText, is as follows: If (

The function will return true if, for each word in needles, there is at least one word in haystack that begins with that word. This will be used to iterate through all the words in the haystack. When calling this function, we would almost always pass the number 1.


Global fields can be accessed from any context whether or not a relationship exists between the tables. Tip: To keep your data tables clean and better organized, I recommend having a separate table to hold global fields that are not directly associated with a particular table.
