Scriptable Object Component |
Although Mathcad has several application-specific components, you can exchange data between a Mathcad worksheet and any other application, as long as that application supports OLE Automation. The Scriptable Object component allows you to control any OLE application, including Mathcad, installed on your computer. Before using the Scriptable Object component, you should be proficient in a supported scripting language and understand how the other application has implemented OLE.
![]() |
Inserting a Scriptable Object Component |
When you insert a Scriptable Object component the Scripting Wizard launches to guide you through the configuration process.
On the first page of the Wizard you must select the object to script. You can either create an empty component or create one based upon a particular application file.
The second page of the Wizard allows you to specify the scripting language used by the component. Although you can script objects using any scripting language available on your computer, Mathsoft officially supports two scripting languages, VBScript and JScript. If you select either of these options, Mathcad creates a script shell containing the appropriate event handlers. For any other scripting language, Mathcad creates an empty script.
On the third page of the Wizard, you can specify a name for the object. You use this name in the script to refer to the object when calling its automation interface. You can also specify the number of input and output variables associated with the component.
For more information on Microsoft's scripting languages and to download the latest versions, refer to Microsoft Inc.'s Web site, http://msdn.microsoft.com/scripting.
![]() |
Configuring A Scriptable Object Component |
Right-clicking on a Scripted object and selecting Properties allows you to set the number of input and output variables, change the name of the object, and edit the script associated with the component. When configuring the component, keep the following limitations in mind:
The Scripted Object component supports a maximum of four inputs and four outputs.
If you change the name of the component on the Properties page, you must manually update the name in the script or the component returns an error when you evaluate it.
You can switch scripting languages after you insert the component but you must completely rewrite the script, including the event handlers. You cannot switch languages within a script.
Your script must write to every output variable. Any variable it does not write to is undefined and the component returns an error.
Scripted objects can be exported for reuse, allowing you to insert them in other worksheets or distribute them to other users.
The Developer's Reference provides more information about the Scriptable Object component.
Mathcad can protect you from potentially damaging code within Scriptable Object components. By default, you are prompted to enable or disable evaluation of scriptable components upon opening a worksheet containing them. The security level can be set on the Script Security tab of the Preferences dialog.