Difference between revisions of "Right"

From Second Life Wiki
Jump to navigation Jump to search
(New page: {{LSL Header}} __NOTOC__ <div id="box"> == Function: string right(string {{LSL Param|src}}, string {{LSL Param|divider}}); == <div style="padding: 0.5em;"> Returns text right o...)
 
(style, optimization and bug fixes.)
Line 1: Line 1:
{{LSL Header}} __NOTOC__
{{LSL_Function
<div id="box">
|mode=user
== Function: [[string]] right([[string]] {{LSL Param|src}}, [[string]] {{LSL Param|divider}}); ==
|func=right
<div style="padding: 0.5em;">
|p1_type=string|p1_name=src
Returns text right of a specified separator
|p2_type=string|p2_name=divider
|return_type=integer
|return_text=that is the text in '''src''' that is right of the first occurrence of '''divider'''.  
|func_desc=Returns text right of a specified separator
|func_footnote=
You can, for example, loop through a list, passing it extracted values from the list and the mask, and it will let you pull out items from the list which are a valid match according to the mask criteria you specified.
 
If '''divider''' is not found then '''src''' is returned in it's entirety.


See also: [[Left]]
See also: [[Left]]
 
|examples=
Example:<br />
<lsl>string value = right("Colour=Brown", "="); //value == "Brown"</lsl>
 
|spec=<lsl>string right(string src, string divider) {
string notecardparameter = right(sdata,"=");
    integer index = llSubStringIndex( src, divider );
//in a notecard line that reads Colour=Brown, returns "Brown"
    if(~index)
 
        return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
 
    return src;
</div></div>
}</lsl>
<div id="box">
|helpers
== Specification ==
|also_functions
<div style="padding: 0.5em;">
|also_events
<lsl>
|also_tests
string right (string src, string divider) {
|also_articles
      integer iStart = llSubStringIndex( src, divider ) + 1;
|location=
      string result = llGetSubString( src, iStart, llStringLength(src) - 1 ) ;
Posted here with the kind permission of {{User|Very Keynes}}. Originally posted February 2008 at http://forums.secondlife.com/showthread.php?t=243445 .
      return result;
|notes
}
|cat1=Examples
 
|cat2
</lsl>
|cat3
</div></div>
|cat4
 
}}
{{LSLC|Examples|right}}

Revision as of 18:47, 14 July 2008

Summary

Function: integer right( string src, string divider );

Returns text right of a specified separator
Returns an integer that is the text in src that is right of the first occurrence of divider.

• string src
• string divider

You can, for example, loop through a list, passing it extracted values from the list and the mask, and it will let you pull out items from the list which are a valid match according to the mask criteria you specified.

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

See also: Left

Specification

<lsl>string right(string src, string divider) {

   integer index = llSubStringIndex( src, divider );
   if(~index)
       return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
   return src;

}</lsl>

Examples

<lsl>string value = right("Colour=Brown", "="); //value == "Brown"</lsl>

Deep Notes

Source

Posted here with the kind permission of Very Keynes. Originally posted February 2008 at http://forums.secondlife.com/showthread.php?t=243445 .

Signature