StringTruncate: Difference between revisions
Jump to navigation
Jump to search
Ugleh Ulrik (talk | contribs) m moved User:Ugleh Ulrik/trimstring to Truncate: Truncate is the correct definition of what its doing. |
Ugleh Ulrik (talk | contribs) m moved Truncate to StringTruncate: -.- Forgot to put string in the title |
(No difference)
| |
Revision as of 15:33, 30 May 2010
Not to be confused with LlStringTrim.
this function will trim a string if it is too long.
Function
<lsl>
string trimstring(string text, integer length) {
if (length < llStringLength(text)){
length = length-1;
string newstring = llGetSubString(text,0, length) + "...";
return newstring;
}else{
return text;
} } </lsl>
Example <lsl> string trimstring(string text, integer length) {
if (length < llStringLength(text)){
length = length-1;
string newstring = llGetSubString(text,0, length) + "...";
return newstring;
}else{
return text;
} }
default {
state_entry()
{
// llSay(0, "Hello, Avatar!");
}
touch_start(integer total_number)
{
llSay(0,trimstring("Thisismyname Ulrik",11));
}
} </lsl>