WoW:API pcall: Difference between revisions
Jump to navigation
Jump to search
pcall -Documentation by Darjk-
mNo edit summary |
mNo edit summary |
||
Line 38: | Line 38: | ||
__NOTOC__ | __NOTOC__ | ||
{{Template:WoW API}} | {{Template:WoW API}} | ||
[[Category:API Functions|pcall]] | |||
[[Category:API LUA Functions|pcall]] | [[Category:API LUA Functions|pcall]] |
Revision as of 18:41, 29 August 2005
Returns a boolean value to catch errors from the function call (func).
retVal = pcall (func, arg1, arg2, ...);
Parameters
Arguments
- (func, arg1, arg2, ...)
- func
- Function - The function that will be called (from within) pcall().
- arg1
- Variable - Any variable that is also to be passed with the function when its called (if any).
- arg2
- Variable - Same as arg1.
Returns
- Returns
- retVal
- retvaL
- Boolean - If the call to the function (that was passed to pcall) succeeded, returns true. If an error occured, returns false.
Example
function myTest() local strTest = "I am a string"; strTest = strTest + 10; end local retVal = pcall(myTest());
Result
pcall will catch the error that occured within 'myTest' and return false.
retVal = false;
Details
- pcall will also return other arguments returned from the "function" if all is successful.