StringTruncate

From Second Life Wiki
Revision as of 18:34, 20 April 2010 by Ugleh Ulrik (talk | contribs) (Created page with '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) { length ...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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) {

   length = length-1;
   string newstring = llGetSubString(text,0, length) + "...";
   return newstring;

} </lsl>

Example <lsl> string trimstring(string text, integer length) {

   length = length-1;
   string newstring = llGetSubString(text,0, length) + "...";
   return newstring;

}

default {

   state_entry()
   {
      // llSay(0, "Hello, Avatar!");
   }
   touch_start(integer total_number)
   {
       llSay(0,trimstring("Thisismyname Ulrik",11));
   }

} </lsl>