Lasso Soft Inc. > Home


AuthorJohn Burwell
LicensePublic Domain
Posted19 Apr 2006
Updated19 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.

Sample Usage

[String_Truncate: $long_string, -Length=20, -Ellipsis='...']

Source Code

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',
  -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;
    Return: (String_Extract: #input_string, -StartPosition=1, -EndPosition=#max_length) + #postfix_string;


Related Tags


No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home



©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft