Difference between revisions of "Left"

From Second Life Wiki
Jump to navigation Jump to search
(Undo revision 1142069 by Opensource Obscure (Talk) + string)
m (<lsl> tag to <source>)
 
Line 12: Line 12:
See also: [[Right]]
See also: [[Right]]
|examples=
|examples=
<lsl>string value = left("Colour=Brown", "="); //value == "Colour"</lsl>
<source lang="lsl2">string value = left("Colour=Brown", "="); //value == "Colour"</source>
|spec=<lsl>string left(string src, string divider) {
|spec=<source lang="lsl2">string left(string src, string divider) {
     integer index = llSubStringIndex( src, divider );
     integer index = llSubStringIndex( src, divider );
     if(~index)
     if(~index)
         return llDeleteSubString( src, index, -1);
         return llDeleteSubString( src, index, -1);
     return src;
     return src;
}</lsl>
}</source>
|helpers
|helpers
|also_functions
|also_functions

Latest revision as of 16:24, 24 January 2015

Summary

Function: string left( string src, string divider );

Returns text left of a specified separator
Returns a string that is the text in src that is left of the first occurrence of divider.

• string src
• string divider

If divider is not found then src is returned in it's entirety.

See also: Right

Specification

string left(string src, string divider) {
    integer index = llSubStringIndex( src, divider );
    if(~index)
        return llDeleteSubString( src, index, -1);
    return src;
}

Examples

string value = left("Colour=Brown", "="); //value == "Colour"