interrupt a computation in OpenMaple - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : VB Application Programming Interface : Session State and Input-Output Functions : OpenMaple/VB/queryInterrupt

queryInterrupt - interrupt a computation in OpenMaple

Calling Sequence





user_data pointer passed to StartMaple ()



This OpenMaple function is part of the MapleCallBack structure passed as an argument to StartMaple.


The queryInterrupt function allows the user to halt computation. This function is called before each Maple statement is executed. In general, this occurs hundreds of times per second. For some operations (notably large integer manipulations), the queryInterrupt function is called only every few seconds.


The prototype for the function that you can assign to the entry in the MapleCallBack must look like the following.

Function QueryInterrupt(ByVal data As Long) As Long


To halt the computation, the function must return True. To continue the computation, the function must return False.


The data parameter contains the same data as passed to StartMaple in the user_data parameter.


Public ShouldStop As Boolean

ShouldStop = False

Public Function QueryInterrupt(ByVal data As Long) As Long

   If ShouldStop Then

       MainForm.StopButton.Caption = "Stop"

       ShouldStop = False

       QueryInterrupt = True


       QueryInterrupt = False

   End If

End Function

Private Sub StopButton_Click()

   If Screen.MousePointer = vbHourglass Then

       ShouldStop = True

       StopButton.Caption = "Stopping ..."

   End If

End Sub

' assignment to MapleCallback entry

cb.lpQueryInterrupt = GetProc(AddressOf QueryInterrupt)

' test statement that will invoke the CallBackCallBack

EvalMapleStatement kv, "do end do;"  'infinite loop

See Also

callBackCallBack, errorCallBack, OpenMaple, OpenMaple/VB/API, OpenMaple/VB/Examples, readLineCallBack, redirectCallBack, StartMaple, statusCallBack, streamCallBack, textCallBack

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