Difference between revisions of "Return"
Jump to navigation
Jump to search
Jeff Kelley (talk | contribs) |
(<lsl> example) |
||
Line 25: | Line 25: | ||
</div> | </div> | ||
}}{{#vardefine:examples| | }}{{#vardefine:examples| | ||
< | <lsl>integer Goodbye() | ||
integer Goodbye() | |||
{ | { | ||
llOwnerSay("Goodbye"); | llOwnerSay("Goodbye"); | ||
Line 36: | Line 35: | ||
llOwnerSay("Hello"); | llOwnerSay("Hello"); | ||
return; | return; | ||
} | }</lsl> | ||
</ | |||
}}{{#vardefine:notes| | }}{{#vardefine:notes| | ||
}}{{#vardefine:caveats|*There is a bug in the compiler and it will let you return a value with events, which when encountered at runtime will cause the script to crash. | }}{{#vardefine:caveats|*There is a bug in the compiler and it will let you return a value with events, which when encountered at runtime will cause the script to crash. |
Revision as of 07:29, 11 February 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
- The correct title of this article is return. The initial letter is shown capitalized due to technical restrictions.
return value;
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.
Functions
- Exits the function and continues script execution in the previous scope.
Events
- Causes the script to crash. Events cannot return a value. Use the next form of this keyword instead.
return;
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.
Functions
- Exits the function and continues script execution in the previous scope.
Events
- Exits the event and removes it from the event queue. If there is another event in the queue, that event is triggered.
Caveats
- There is a bug in the compiler and it will let you return a value with events, which when encountered at runtime will cause the script to crash.
- Do not try to return a value in the event scope if you do not wish your script to crash.
Examples
<lsl>integer Goodbye() {
llOwnerSay("Goodbye"); return 0;
}
Hello() {
llOwnerSay("Hello"); return;
}</lsl>