Difference between revisions of "LSL 101/String Concatenation"
< LSL 101
Jump to navigation
Jump to search
m (where is the rest of the article???) |
|||
Line 2: | Line 2: | ||
{{NavNextPrev|prev=Functions That Return a Value|next=}} | {{NavNextPrev|prev=Functions That Return a Value|next=}} | ||
String concatenation allows us to combine two or more strings into a single string, as if they were simply pasted together. Here's an example where we use string concatenation to put the region name into a complete sentence. | |||
<lsl> | <lsl>default | ||
default | |||
{ | { | ||
state_entry() | state_entry() | ||
Line 18: | Line 17: | ||
llOwnerSay( "Welcome to " + llGetRegionName() + "." ); | llOwnerSay( "Welcome to " + llGetRegionName() + "." ); | ||
} | } | ||
} | }</lsl> | ||
The + sign, when used with strings, indicates concatenation. This is analogous to the use of + in integer addition | |||
As in the previous example, the server executes ''llGetRegionName'' and reduces the line to the equivalent of | |||
llOwnerSay( "Welcome to " + "Ganymede" + "." ); |
Revision as of 11:24, 21 May 2009
← Functions That Return a Value | ↑̲ LSL 101 ̲↑ |
String concatenation allows us to combine two or more strings into a single string, as if they were simply pasted together. Here's an example where we use string concatenation to put the region name into a complete sentence.
<lsl>default {
state_entry() { // Let the object's owner know the script is working llOwnerSay( "Congratulations! Your script has started to execute." ); } touch_start( integer num_detected ) { // Let the object's owner know the script is working llOwnerSay( "Welcome to " + llGetRegionName() + "." ); }
}</lsl>
The + sign, when used with strings, indicates concatenation. This is analogous to the use of + in integer addition
As in the previous example, the server executes llGetRegionName and reduces the line to the equivalent of
llOwnerSay( "Welcome to " + "Ganymede" + "." );