Link | string_truncate9 |
Author | Jonathan Guthrie |
Category | String |
Version | 9.x |
License | Public Domain |
Posted | 05 Nov 2010 |
Updated | 05 Nov 2010 |
More by this author... |
String_Truncate takes three parameters: an input string, a -Length integer, and an optional -Ellipsis string. It returns a string no longer than the specified -Length, appending the optional ellipsis if the string is actually truncated. If the input string is shorter than the specified length, the full input string is returned and no ellipsis is appended. Note: The length of the ellipsis is not counted when truncating the input string. The string is truncated to the specified length before the ellipsis is added.
Note, this is a port of John Burwell's tag for 8.x
http://tagswap.net/String_Truncate/
string_truncate(#mystring,10) string_truncate(#mystring,-length=10,-ellipsis='...')
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define string_truncate(string::string,length::integer,ellipsis::string='...') => { // Returns a string truncated to the specified -Length. An optional -Ellipsis parameter specifies a string to append if the string is actually truncated. if(#string->Size <= #length) => { return #string else return string_extract(#string, -StartPosition=1, -EndPosition=#length) + #ellipsis } } define string_truncate(string::string,-length::integer,-ellipsis::string='...') => { return string_truncate(#string,#length,#ellipsis) }
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft