raise a Maple error in external code - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : VB Application Programming Interface : Evaluation and Error Handling : OpenMaple/VB/MapleRaiseError

MapleRaiseError - raise a Maple error in external code

MapleRaiseError1 - raise a Maple error in external code

MapleRaiseError2 - raise a Maple error in external code

Calling Sequence

MapleRaiseError(kv, msg)

MapleRaiseError1(kv, msg, arg1)

MapleRaiseError2(kv, msg, arg1, arg2)




kernel handle returned by StartMaple



error message

arg1, arg2


Maple objects



These functions are part of the OpenMaple interface to Microsoft Visual Basic.


These functions raise the Maple error described by msg, equivalent to the Maple command error(msg,arg1,arg2);.


When an error is raised, the errorCallBack is invoked, and execution continues at the next statement. OpenMaple interrupts a computation at an error invoked by MapleRaiseError when the external function is launched via MapleTrapError.


The character string msg can contain wildcards of the form %N, where N is a non-zero integer. These wildcards are replaced by the extra argument, arg1 or arg2, before displaying the message. If %-N is specified, then the optional argument is displayed with the appropriate suffix, st, nd, rd, or th, appended. For example, consider the following command.

MapleRaiseError2kv, "the %-1 argument, '%2', is not valid",

    ToMapleInteger(i), args(i)


This, if invoked, raises the error, "the 4th argument, 'foo', is not valid", assuming i=4, and args(i) is set to the Maple name, foo. For more information, see error. The only option not allowed is %0 because the function cannot determine the number of unparsed optional arguments.


Sub MyGuessInput(ByVal kv As Long)

    Dim i, n As Long

    For i = 1 To 10

        n = MapleToInteger32(kv, EvalMapleStatement(kv, "rand(-10..10)();"))

        If n <= 0 Then

            MapleRaiseError1 kv, "%1 is too small", ToMapleInteger(kv, n)

        ElseIf n > 1 Then

            MapleRaiseError1 kv, "%1 is too big", ToMapleInteger(kv, n)

        End If

    Next i

End Sub

See Also

OpenMaple, OpenMaple/VB/API, OpenMaple/VB/Examples

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam