Return
A return is a
value given when exiting a
function or
event. The
return keyword is used for exiting from functions or events. If a function has a return value, all
code paths will need to end in a return
statement.
Note: The term "return value" is used when referring to the value retrieved by
calling a function.
Also, there is not currently a function to return
objects from a
land parcel--that's not what this keyword does.
Example:
MyGlobalFunction(string str) {
llSay(0, str);
}
float WithReturnValue() {
float r;
r = llFrand(10);
return r; // also valid: return(r);
}
default {
touch_start(integer total_number) {
if ( llDetectedKey(0) != llGetOwner() ) return; // exit this event if touched by stranger
MyGlobalFunction("Hooray for SL!"); // call a function without return value
llSay(0, (string)WithReturnValue()); // call function and use the return value
WithReturnValue(); // discarding the return value is also legal
}
}
Flow Control |
Glossary