MapleEval - Maple Programming Help

Online Help

All Products    Maple    MapleSim

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


evaluate a Maple object in external code


evaluate a Maple function object in external code


parse and evaluate a command string in external code


Calling Sequence




Calling Sequence

MapleEval(kv, s)

EvalMapleProcedure(kv, fn, args)

EvalMapleStatement(kv, statement)




kernel handle returned by StartMaple



Maple object



Maple name or procedure object



Maple expression sequence object



command string



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


The EvalMapleStatement function parses and executes the command string given in the statement argument. MapleAssign can be used to give external objects names that can be referenced in a command string.  The command string must be terminated by a colon or semicolon.  When using this command in OpenMaple, a colon suppresses the display of output.


The MapleEval function evaluates the given Maple object, s. Evaluation is performed according to the rules used by the eval command.


The EvalMapleProcedure function invokes the procedure, fn(args), where args is an expression sequence of arguments, possibly created by NewMapleExpressionSequence. If args is a single item, that object can be passed in directly instead of creating an expression sequence. The result of the evaluation is returned as a Maple object. The fn parameter must be a name or procedure object.


Sub SampleStats(ByVal kv As Long)

    Dim mean, sd, f, list, args As Long

    ' create a data list

    list = MapleListAlloc(kv, 6)

    MapleListAssign kv, list, 1, ToMapleInteger(kv, 1)

    MapleListAssign kv, list, 2, ToMapleInteger(kv, 33)

    MapleListAssign kv, list, 3, ToMapleInteger(kv, 42)

    MapleListAssign kv, list, 4, ToMapleInteger(kv, 50)

    MapleListAssign kv, list, 5, ToMapleInteger(kv, 55)

    MapleListAssign kv, list, 6, ToMapleInteger(kv, 67)

    ' build the argument expression sequence

    args = NewMapleExpressionSequence(kv, 1)

    MapleExpseqAssign kv, args, 1, list

    ' get the name of the function to call, and compute the mean

    f = EvalMapleStatement(kv, "Statistics[Mean];")

    mean = EvalMapleProcedure(kv, f, args)

    Write #1, "Mean", MapleToFloat64(kv, mean)

    ' compute the standard deviation using a different method -- build

    ' up the function object and call MapleEval on it

    f = EvalMapleStatement(kv, "Statistics[StandardDeviation];")

    f = ToMapleFunction(kv, f, args)

    sd = MapleEval(kv, f)

    Write #1, "Standard Deviation", MapleToFloat64(kv, sd)

End Sub

See Also






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