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 "<br />" as the linebreak_char to generate the correct (X)HTML to be displayed in the link. My FileMaker field calculation looked something like this:
<a href=\"" &
If ( Left ( uri ; 4 ) = "http"; ""; "http://") &
uri & "\">" & WrapURI ( uri ; 20 ; "<br />") & "</a>"
With the uri in the sample input, this calculation would generate:
Find the closest locations by zip code using FileMaker. Click
here.
Custom Function Authors:
Link to all of your own custom functions on this site with the following URL:
http://www.briandunning.com/filemaker-custom-functions/results.php?author=Your
Name Here