Brian Dunning's FileMaker Custom Functions

ExtractListFromHtml ( AnyText ; Html ; theStartTag ; theEndTag )

Recursive function, returns a list of every possible subset, of any length, of characters contained between theStartTag and theEndTag.

  Average rating: 5.0 (1 vote) Log in to vote

Gennaro BONATESTA   Gennaro BONATESTA - Show more from this author
Tenuta TRESCA
https://www.tresca.it

Share on Facebook Share on Twitter

  Sample input:
ExtractListFromHtml (
"LIST" & ¶ ;
"span class=\"text\">Anna Fontana/span> " & ¶ &
"span class=\"text\">Annamaria Di Pinto/span> " & ¶ &
"span class=\"text\">Antonio Palumbo/span>" ;
"span class=\"text\">" ;
"/span>"
)
  Sample output:
LIST
Anna Fontana
Annamaria Di Pinto
Antonio Palumbo

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

WHY THIS TECHNIQUE IS NEEDED:

1. FileMaker custom functions do not support looping statements (Do, While, For-Next) or line-jumping (GoTo).

2. FileMaker custom functions do not support the use of "optional parameters" (parameters that do not have to be included with the function call), which might help to simulate some of the above functions.

The code demonstrated in this function shows how to create a conditional loop using Case(), Let(), Recursion, and a local script variable ("$", not "$$").

Using this technique, you can create a loop with the ability to perform different actions at each "step" in the loop (1, 2, 3, etc.).

DEPENDENCIES:

1. Tested using FileMaker 17 - should work from v15.

2. Has dependencies on the custom function ParseData ( theText ; theStartTag ; theEndTag ; theOccurance ) - https://www.briandunning.com/cf/559.

NOTES:

1. I did not invent this technique. It has been in existence for a long time. I am just showing a simple example for people who want to include some sort of looping mechanism inside of a FileMaker custom function, and haven't tried this method before.

2. FileMaker has a limit of 10,000 nested recursions per function call. Therefore, it makes sense to use this technique for an internal loop counter, but it is not good to use this technique for looping through large data sets (in that case, you might want to check out the looping capabilities of FileMaker scripts, which have fewer limits).

3. You will need a copy of "FileMaker Advanced" to *create* a custom function, but functions that have been created with "FileMaker Advanced" and saved into a database, can be freely used by "FileMaker Pro" clients who access that database.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.