Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
MapleTrapError - trap a Maple error in external code
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):")
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