Controls > Advanced Controls > Events for Scriptable Controls > Events for Scriptable Controls
Events for Scriptable Controls
The advanced scriptable controls use an event-driven model. The model defines three basic events:
Start
Exec
Stop
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), or when a user clicks or pushes a button. In addition, you can use the events defined for advanced controls: buttons, radio buttons, list boxes, checkboxes, text boxes and sliders.
Use the Start event to set the properties that need to be set only once for the control. The Exec event and the other control-specific events are used to set properties that are needed for interactions with the control, and for creating outputs.
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
JScript event handlers are case sensitive, whereas VBScript's are not. JScript's event mechanism specifies the event by the object name followed by an underscore (_) followed by the event name.
function MyEventSrc_Event1()
{
// add your code here
}
Was this helpful?