Scripting an Object |
In order to use most components, you must create a script to control the object. Mathcad comes with a Script Editor, where you can write and maintain the script for each scripted object in your worksheet.
You can also save scripts for reuse with other scripted objects. Select Export from the File menu to save a copy of the script to disk. To use a saved script in a component, select Import from the File menu. When you import a script, check that the object name in the script matches the object name in the worksheet.
![]() |
Structure of a Script |
There are three required parts to each script, called event handlers. These three event handlers are called in sequence every time a component calculates.
The Start Event, which executes when the component is calculated.
The Exec Event, which executes after the Start Event is finished. This Event has arguments Inputs and Outputs that correspond to the input and output variables for the component; use notation like Inputs(0) and Outputs(1) in the body of the subroutine to refer to the first input and the second output.
The Stop Event, which executes following the Exec event.
For more specific information on how to script objects and Mathsoft Controls, see the Developer's Reference under the Help menu. Regardless of which scripting language you use, your script must contain these three event handlers. You can use other event handlers if you wish, but they are not required. A basic framework containing these event handlers is preloaded for any new scriptable component you create.