StartMaple - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


StartMaple

start an OpenMaple session

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

StartMaple(NumArgs, argv, cb, user_data, err)

Parameters

NumArgs

-

number of startup command-line arguments (Long)

argv

-

startup command-line arguments (String array)

cb

-

callback vector (MapleCallBack)

user_data

-

data passed during invocation of callbacks (Long)

err

-

string buffer (String)

Description

• 

This function is part of the OpenMaple interface to Microsoft Visual Basic.

• 

The StartMaple function initializes an OpenMaple session.  When successful, a session handle is returned.  This handle is needed as an argument to all OpenMaple API functions.

• 

To use the VB OpenMaple code and examples shown in these help pages, first add the extern/include/maple.bas file to your project. This file is in your Maple installation.

• 

Startup options described in ?maple can be used for starting OpenMaple by specifying them in argv.  For example, to load the initialization file, /home/myinit, at startup, set argv(1) = "-i", and argv(2) = "/home/myinit".  If these are the only arguments, set argc = 2.

• 

If initialization fails, StartMaple returns 0 and fills the string provided in the err parameter.

• 

The user_data parameter is an arbitrary user-supplied value. It is the first argument passed to the callback functions.

• 

The cb parameter specifies a collection of functions that Maple uses to return results to your application.  The MapleCallBack structure is filled with the address of functions that match the following prototypes.

    Sub lpTextCallBack(ByVal data As Long,

     ByVal tag As Integer,

     ByVal Output As Long)

    Sub lpErrorCallBack(ByVal data As Long,

     ByVal Offset As Integer,

     ByVal Output As Long)

    Sub lpStatusCallBack(ByVal data As Long,

     ByVal kilobytesUsed As Long,

     ByVal kilobytesAlloc As Long,

     ByVal CPUTime As Double)

    Function lpReadLineCallBack(ByVal data As Long,

     ByVal dbug As Long) as Long

    Function lpRedirectCallBack(ByVal data As Long,

         ByVal name as Long,

     ByVal mode As Long) as Long

    Function lpStreamCallBack(ByVal data As Long,

         ByVal name as Long,

         ByVal nargs as Long,

     ByVal args As Long) as Long

    Function lpQueryInterrupt(ByVal data As Long) As Long

    Function lpCallBackCallBack(ByVal data As Long,

         ByVal Output as Long) as long

• 

Note that the Output parameters are character array pointers, which can be converted to VB Strings using MaplePointerToString(Output).

• 

All callback functions have defaults that direct output to another callback, or to stdout.  To use the default, set the function pointer to 0.  It is recommended that you always define a textCallBack function.

• 

Each function takes one or more parameters. All take a generic data parameter. The data parameter is passed the value of the user_data parameter given to StartMaple.

• 

For more information on the callback functions, see ?textCallBack, ?errorCallBack, ?statusCallBack, ?readLineCallBack, ?redirectCallBack, ?streamCallBack, ?queryInterrupt, and ?callBackCallBack.

Examples

Private Sub Form_Load()

    Dim error As String

    Dim args(1 To 2) As String

    'init args

    args(1) = "-c"

    args(2) = "assign(blah,33)"

    'init callbacks

    cb.lpTextCallBack = GetProc(AddressOf TextCallBack)

    cb.lpErrorCallBack = GetProc(AddressOf ErrorCallBack)

    cb.lpStatusCallBack = GetProc(AddressOf StatusCallBack)

    cb.lpReadLineCallBack = 0

    cb.lpRedirectCallBack = 0

    cb.lpStreamCallBack = 0

    cb.lpQueryInterrupt = GetProc(AddressOf QueryInterrupt)

    cb.lpCallBackCallBack = 0

    ' start Maple

    kv = StartMaple(2, args, cb, 0, error)

    If kv = 0 Then

        MsgBox "Error starting Maple: " + error, vbCritical, ""

        End

    End If

    EvalMapleStatement kv, "blah;"

    StopMaple kv

End Sub

See Also

callBackCallBack

errorCallBack

OpenMaple

OpenMaple/VB/API

OpenMaple/VB/Examples

queryInterrupt

readLineCallBack

redirectCallBack

RestartMaple

statusCallBack

StopMaple

streamCallBack

textCallBack

trademarks