WoW:API pcall: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 38: Line 38:
__NOTOC__
__NOTOC__
{{Template:WoW API}}
{{Template:WoW API}}
[[Category:API Functions|pcall]]
[[Category:API LUA Functions|pcall]]

Revision as of 15:04, 4 January 2006

pcall -Documentation by Darjk-

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.

Template:WoW API