PythonScript Xojo Plugin |

# PythonXojoModule.RegisterFunction Method (console safe)

Registers a Xojo function to expose to Python via this module

RegisterFunction(
name as String,
fuction as Ptr)

#### Parameters

name
  Name of the function as Python should see it. This name does not have to be same as the name of the Xojo function.
fuction
  Address of the Xojo function that should by called from Python.
  Note
  The parameters and return value must always be as follows:
  SomeFunctionName(pySelf as Ptr, pyArgs as Ptr) as Ptr

#### Remarks

Example function in Xojo with correct function parameters and result value:

Function CalculateSomething(pySelf as Ptr, pyArgs as Ptr) As Ptr
Dim params as PythonParameters = new PythonParameters(pyArgs)
if params.Count = 2 then
return PythonResult(new PythonResult(params.IntegerValue(0) + params.IntegerValue(1))).GetPtr()
else
PythonScript.SetError(PythonErrorTypes.TypeError,"CalculateSomething must have exactly 2 parameters")
return nil
end if
End Function

#### See Also

PythonXojoModule Class