Events for Scriptable Objects and Controls

The scripting component uses an event-driven model framework. The model defines three basic events:

These are triggered by Mathcad as the worksheet is recalculated, when internal scripted conditions have been met (such as when data is received back from an external application), when a user clicks or pushes a button, or when a file is read and converted. In addition, you may wish to use the events defined for Mathsoft Controls: buttons, list boxes, and sliders.

There will be event functions associated with any scriptable OLE object’s type library. Check the Automation reference for any application which you are trying to script in order to provide appropriate event handler functions in a Mathcad component, as required.

Syntax in VBScript and JScript

The event function syntax is language-specific. Most scripting languages provide a standard mechanism for event functions, usually a combination of the object which defines the event ("sources" the event) and the name of the event. VBScript, for example, uses the name of the event source, followed by an underscore, followed by the event name.

Sub MyEventSrc_Event1()
      'add your code here
End Sub

The examples in this section use this VBScript syntax for the Start, Exec, and Stop events, as well as for those associated with the Mathsoft Controls classes. JScript event handlers are case sensitive, whereas VBScript's are not. JScript's event mechanism specifies the event by the object name followed by a double colon (::) followed by the event name.

function MyEventSrc::Event1()

{
     // add your code here
}