MapleTrapError
trap a Maple error in external code
Calling Sequence
Parameters
Description
Examples
MapleTrapError(kv, f, data, err)
kv
-
kernel handle returned by StartMaple
f
function pointer
data
integer data
err
boolean flag set to True if an error occurs executing f
This function is part of the OpenMaple interface to Microsoft Visual Basic.
The MapleTrapError function attempts to execute the VB function f(data). If a Maple error is raised at any time during execution of f, the function returns immediately after setting err to True.
Use the GetProc and AddressOf commands to get the address of a VB function as shown in the example below.
This function can be used to abort function calls when MapleRaiseError is invoked.
dim global_kv as long
Public Function TestTrapErrorCB1(data As Long) As Long
MapleRaiseError global_kv, "test"
TestTrapErrorCB1 = data
End Function
Public Function TestTrapErrorCB2(data As Long) As Long
TestTrapErrorCB2 = EvalMapleStatement(global_kv, "int(x,x):")
Public Sub TestTrapError(ByVal kv As Long)
Dim errorflag As Long
Dim data As Long
global_kv = kv
data = MapleTrapError(kv, GetProc(AddressOf TestTrapErrorCB1), _
365, errorflag)
If errorflag = 0 Then
MsgBox "should have been an error (errorflag = 1)", _
vbInformation, ""
End If
data = MapleTrapError(kv, GetProc(AddressOf TestTrapErrorCB2), _
0, errorflag)
If errorflag = 1 Then
MsgBox "should NOT have been an error (errorflag = 0)", _
vbInformation, """"
End Sub
See Also
error
OpenMaple
OpenMaple/VB/API
OpenMaple/VB/Examples
traperror(deprecated)
Download Help Document