Link | String_Truncate |
Author | John Burwell |
Category | String |
Version | 8.x |
License | Public Domain |
Posted | 19 Apr 2006 |
Updated | 19 Apr 2006 |
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.
[String_Truncate: $long_string, -Length=20, -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_Tag: 'String_Truncate', -Required='String', -Required='Length', -Optional='Ellipsis', -Description='Returns a string truncated to the specified -Length. An optional -Ellipsis parameter specifies a string to append if the string is actually truncated.'; Local: 'input_string' = (String: (Local: 'String')); Local: 'max_length' = (Integer: (Local: 'Length')); Local: 'postfix_string' = (String: (Local: 'Ellipsis')); If: #input_string->(Size) <= #max_length; Return: #input_string; Else; Return: (String_Extract: #input_string, -StartPosition=1, -EndPosition=#max_length) + #postfix_string; /If; /Define_Tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft