Lasso Soft Inc. > Home

[gf_lowtext]

Linkgf_lowtext
AuthorGaetano Frascolla
CategoryString
Version8.x
LicensePublic Domain
Posted14 Jul 2006
Updated14 Jul 2006
More by this author...

Description

Based on [string_truncate] tag created by John Burwell, gf_lowtext returns truncated text to specified chars without truncate words, and add a suffix at the end of the string. It takes three params: an input -text, the lenght of the output and an optional suffix for the output. If the result ends with truncated word, this tag will remove the remaining chars, and will return a clean string.

Sample Usage

[gf_lowtext: -text=($text), -chars=40, -suffix='...']

example:

gf_lowtext:
-text='Click the "Download" button below to retrieve a copy of this tag',
-chars=40,
-suffix='...'

Only truncate:

Click the "Download" button below to retr...

Truncate and Clean

Click the "Download" button below to...

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: 'gf_lowtext',
-required='text',
-required='chars',
-optional='suffix',
-description='Return text truncated to specified chars without truncate words';


Local:'long_text'=(String:(#text));
Local:'chars_lenght'=(Integer:(#chars));
Local:'text_suffix'=(String:(#suffix));

if: #long_text->(Size) > (#chars_lenght);

Local:'new_text'=(#long_text)->(Substring: 1, (#chars_lenght));


While:(string_endswith:(#new_text), -find=' ')=='false';

Local:'chars_lenght'=(#chars_lenght)-1;

Local:'new_text'=(#long_text)->(Substring: 1, (#chars_lenght));

/while;

Local:'chars_lenght'=(#chars_lenght)-1;

Local:'new_text'=(#long_text)->(Substring: 1, (#chars_lenght));


Local:'new_text'	= (#new_text) + (#text_suffix);

return:(#new_text);

else;

return:(#long_text);

/if;


/define_tag;

Related Tags

Comments

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