Brian Dunning's FileMaker Custom Functions

EncodeURL_CF ( textToCode )

Encodes all urls enclosed in square brackets for html.

  Average rating: 4.4 (39 votes) Log in to vote

Paul Spafford   Paul Spafford
Spafford Data Solutions
http://www.paulspafford.com

Share on Facebook Share on Twitter

  Sample input:
EncodeURL_CF ( TextField )

Where TextField contains the following:

FileMaker User and Developer Group of Eastern Ontario:
[http://www.fudgeo.com]

Spafford Data Solutions:
[http://www.paulspafford.com]
  Sample output:
FileMaker User and Developer Group of Eastern Ontario:
http://www.fudgeo.com

Spafford Data Solutions:
http://www.paulspafford.com

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

When creating a multi-part email with an email plug-in, you need to encode any links as html, to make sure that more email applications will allow the links to be clickable.

When writing the text for the email, your users just need to enclose each url in square brackets.

 

Comments

Patryck   Patryck, Barcelona
Jan 17, 2011
This function doesn't loop if you have more than one link. I propose:

//HTMLurl (text;target)

Let( [ FS=Position(text;"*";1;1) ; SS=Position(text;"*";1;2) ; URL=Middle(text;FS+1;SS-FS-1);

A= Substitute( text; Middle(text;FS;SS-FS+1) ; "<a href='http://"& URL & "' target='_" &target& "'>"& URL &"</a>" ) ];

If( PatternCount ( text ; "*" ) ≥ 2; HTMLurl( A; target ); text)

)

// transforms all text in between 'star' (exemple: *mydomain.com* ) with the URL link. No need to write the http:// first
// target is to choose if you want to open in self ; blank ; top or new window
// by Patryck 2010
 
Eric.Matthews   Eric.Matthews, SJSU.edu
Aug 12, 2011
This function fails if there's an extra closing bracket. "]".
 
Eric.Matthews   Eric.Matthews, SJSU.edu
Aug 12, 2011
This fixes infinite recursion from mismatched brackets:

Let ( [
@textToCode = textToCode
; @openSquarePos = Position ( @textToCode ; "[" ; 1 ; 1 )
; @closeSquarePos = Position ( @textToCode ; "]" ; @openSquarePos;1 )
// Search from "@openSquarePos;1" not "1;1" Eric.Matthews sjsu.edu

; @afterOpenSquare = Right ( @textToCode ; Length ( @textToCode ) - @openSquarePos )
; @url = Left ( @afterOpenSquare ; @closeSquarePos - @openSquarePos - 1 )
; @encodedUrl = "<a href=\"" & @url & "\">" & @url & "</a>"
; @subbed = Substitute ( @textToCode ; "[" & @url & "]" ; @encodedUrl )
];

Case
( // @openSquarePos and @closeSquarePos" determine completion. Eric.Matthews sjsu.edu
not(@openSquarePos and @closeSquarePos);
@subbed;
EncodeURL_CF ( @subbed )
) // End Case

) // End Let
 
Jens Rasmussen   Jens Rasmussen, Denmark, Eurpoe
Sep 11, 2013
I was experimenting with a version that did not require tags, but would encode 'naturally typed' text.
Also, I would want several link types/protocols:
- http
- https
- mailto
- fmp
- skype

Anyone wanting to take a shot at that?

I am this far in the declaration section:
linkType = "http://" ;
url_start = Position ( text ; linkType ; 1 ; 1 ) ;
url_end = Position ( text ; " " ; url_start ; 1 ) ;
url_length = url_end - url_start ;
url_raw = Middle ( text ; url_start ; url_length ) ;
url_encoded = "<a href=\"" & url_raw & "\">" & url_raw & "</a>" ;
 
Jens Rasmussen   Jens Rasmussen, Copenhagen, Denmark, Europe
Sep 11, 2013
I was experimenting with a version that did not require tags, but would encode 'naturally typed' text.
Also, I would want several link types/protocols:
- http
- https
- mailto
- fmp
- skype

Anyone wanting to take a shot at that?

I am this far in the declaration section:
linkType = "http://" ;
url_start = Position ( text ; linkType ; 1 ; 1 ) ;
url_end = Position ( text ; " " ; url_start ; 1 ) ;
url_length = url_end - url_start ;
url_raw = Middle ( text ; url_start ; url_length ) ;
url_encoded = "<a href=\"" & url_raw & "\">" & url_raw & "</a>" ;
 
Franco   Franco, chennai
May 22, 2015
i just want to send mail through email client via outlook 2007.if i send an attached file without body it executes html otherwise it shows the code in outlook body.is there any function to send an mail containing html codes
 
Franco   Franco, chennai
May 22, 2015
i just want to send mail through email client via outlook 2007.if i send an attached file without body it executes html otherwise it shows the code in outlook body.is there any function to send an mail containing html codes
 

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.

Under construction. Email me your wish list for improvements.