Brian Dunning's FileMaker Custom Functions

WrapURI ( uri ; maxchars ; linebreak_char )

Takes a long URI (a.k.a. URL) and breaks it into multiple lines

  Average rating: 4.5 (41 votes) Log in to vote

Anthony Reimer   Anthony Reimer - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
WrapURI ( "" ; 20 ; "ΒΆ")
  Sample output:

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

This function is similar to WordWrap and Abscind in concept (and borrows liberally from same) but is specific to wrapping URIs (a.k.a. URLs). It tries to break the line at the nearest slash, and if that is not successful, it looks for the nearest dot. If both fail, it does a hard break at whatever the character limit (maxchars) is. It inserts whatever character(s) you supply in the third parameter (linebreak_char) inbetween these "lines."

I needed this function to break some URIs being displayed on a web page (fed by FileMaker) that were in a narrow sidebar. I used "
" as the linebreak_char to generate the correct (X)HTML to be displayed in the link. My FileMaker field calculation looked something like this:

If ( Left ( uri ; 4 ) = "http"; ""; "http://") &
uri & "\">" & WrapURI ( uri ; 20 ; "
") & "

With the uri in the sample input, this calculation would generate:

The link would then look like the sample output.



Log in to post comments.


Note: these functions are not guaranteed or supported by 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 16 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: