MapleTrapError - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


MapleTrapError

trap a Maple error in external code

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

MapleTrapError(kv, f, data, err)

Parameters

kv

-

kernel handle returned by StartMaple

f

-

function pointer

data

-

integer data

err

-

boolean flag set to True if an error occurs executing f

Description

• 

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.

Examples

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):")

End Function

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 If

End Sub

See Also

error

OpenMaple

OpenMaple/VB/API

OpenMaple/VB/Examples

traperror(deprecated)