return value;
| type | value | value or variable to be returned by the function, the type must be the same as that to be returned by the function. |
Used to return execution to the previous scope along with a value.
Used to prematurely return execution to the previous scope before reaching the end of the function/event. You do not need to use this at the end of an event or function, as it is assumed by the compiler.
string get_name(key uuid)
{
return llKey2Name(uuid); // Returns the value of llKey2Name().
}
// Usage within the script:
llOwnerSay("Name: " + get_name( llDetectedKey(0) ) ); // Tell owner what the name is.
integer Calc (string cmd, integer a, integer b)
{
// The user function has been declared as returning an integer,
// so every return within the function must return an integer
if (cmd == "+") return a + b;
// We don't need to code 'else' here, as the preceding statement resulted in 'return' when true
if (cmd == "-") return a - b;
if (cmd == "*") return a * b;
if (cmd == "/") return a / b;
// We must return a value here too, we can't omit the final return
return -1;
}
default
{
state_entry()
{
llSay(0, llList2CSV ( [ Calc("+",1,2), Calc ("-",5,3), Calc ("*",3,4), Calc("/",18,6) ] ) );
}
}
| jump | ||
| state |