linkURLs

Creates an anchor tag around URLs within a string.

Syntax

linkURLs(string, protoString, format, linksOnly, separator)

Parameters

string

Specifies the string in which to search for potential URLs.

protoString

Is reserved.

format

Specifies the format string: {0} refers to the actual link and {1} refers to the non-linked version of the URL.

linksOnly

Specifies whether to return a string containing only the formatted links, or a string containing the original text with the formatted links embedded where they occurred in the original text:

  • true Returns a string that only has the links found in the string parameter. The links will be formatted as per the format parameter, and will be separated by the string specified with the separator parameter.
  • false Returns a string containing the full contents of the string parameter with the formatted links embedded in it as they occurred in the original string.
separator

Specifies the string used to separate links when the linksOnly parameter is set to true (false means the separator is ignored.)

Remarks

LinkURLs is useful for generating an HTML link in text that has a URL. For example, if string contains ? and Novell?s home page is http://www.novell.com.?, an anchor can be created around http://www.novell.com so that the end user can click on it to browse that page.

Assuming Message.message is: Visit http://www.novell.com. And the template contains these lines:

{SET fmtMsg=toHTML(Message.message)}:{VAR linkURLs(fmtMsg, "", "<A href={0}>{1}</A>" false, "")}

The generated output will be:

Visit <A href=http://www.novell.com>http://www.novell.com</A>

Another example is to assume Message.message is: Visit http://www.novell.com and http://developer.novell.com. And the template contains these lines:

{SET fmtMsg=toHTML(Message.message)}:{VAR linkURLs(fmtMsg, "", "<A href={0}>{1}</A>" true, " ")}

The generated output will be:

Visit http://www.novell.com and developer.novell.com (<A href=http://www.novell.com>http://www.novell.com></A>)  (<A href=http://developer.novell.com>http://developer.novell.com></A>)