Accessing External Files and Applications

When you want Mathcad to work with files and functionality from other applications, such as Excel, SmartSketch, or MATLAB, you must first decide whether you want to:

The first task is accomplished through components, described here, the second through the Automation interface.

Components

Components are specialized objects in your Mathcad worksheet created through the Insert menu. Some components allow the exchange of data with other applications or file types. Others can be used to build a user interface for your worksheet, using controls such as sliders and radio buttons.

Components allow data to flow dynamically between the worksheet and a data source or application. Data going into a component are called input, while data returned by a component are called output. A worksheet and a component pass data by way of input and output variables.

Once you have inserted a component into your worksheet, filled in the placeholders, and configured its properties, the component behaves like any other computational region in your worksheet. Data exchange takes place whenever the component is updated, by either configuring the component or updating an input variable, as long as automatic calculation is turned on.

Inserting a Component

To insert a component into a worksheet:

  1. Click in a blank spot of your worksheet. You cannot insert a component into an existing expression.

  2. Depending on the component you want, choose either Component, Data, or Controls from the Insert menu.

  3. For an application component, choose one from the resulting dialog and click "Next." For a data component or a control, choose one from the resulting submenu. Some components are immediately inserted into your worksheet with default properties, while others present a customized Wizard to help you set up the component.

  4. Once the component is visible in your worksheet, specify the input and/or output variable(s) in the placeholders that appear.

Most components send data to and retrieve data from a data source, but some components only accept input or only send output. Therefore, these steps differ slightly for each component, though the ideas presented here should improve your understanding of how components generally work.

Configuring a Component

You may need to change a component's properties, especially if you change the number of input and output variables, so that the component properly handles your data. To configure the properties for a component:

  1. Right-click on the component. The editing lines should only appear around the component and not the input/output variable(s).

  2. Choose Properties from the menu. The settings in the Properties dialog depend on the component.

When you add or remove inputs and/or outputs from a scripted component (Scriptable Object or Mathsoft Control), you must edit the associated script to match the change.

  1. Right-click on the component. The editing lines should only appear around the component, and not the input/output variable(s).

  2. Choose Edit Script from the menu to allow the component to accept data from new inputs and direct output to new outputs.

Notes:

Application Components

Application components give Mathcad access to functions and data from other computational applications. Unlike other kinds of OLE objects, application components can:

Inserting an application component embeds a document for the particular application in your Mathcad worksheet (if the application is installed on your computer). Double-clicking the component replaces Mathcad's menus and toolbars with those of the other application, giving you access to the application without leaving your worksheet. Application components for Excel, MATLAB, and SmartSketch are available by selecting Components from the Insert menu.

You can also use the Scriptable Object component to create custom scripts that automate other OLE applications for which specialized application components are not provided. The Developer's Reference provides detailed information about developing scriptable components.

Data Components

Data components allow you to read values from and write them to data sources such as measurement devices and data files, including ODBC databases. With data components, you cannot directly access the data file itself, but you can control how Mathcad reads it in and assigns it to worksheet variables. The following data components are available from the Data submenu of the Insert menu:

Also available on the Insert Component menu are:

Controls

Controls can be used to drive other OLE applications or control calculations in your worksheet. The following controls are available on both the Controls submenu of the Insert menu and the Controls toolbar:

Check Box

List Box

Push Button

Text Box

Radio Button

Slider

Controls can have both input variables from previous calculations and output variables to be used in future calculations. See the Developer's Reference for more information on scripting the Mathsoft Controls. You can alter the appearance of a control by right-clicking on the component and selecting Mathsoft (Control) Object > Properties from the menu.

To customize a button with a graphic, create the image and copy it to the clipboard. Right-click on your Mathsoft Control component and select Mathsoft (Control) Object > Paste Bitmap from the menu. Alternatively, you can browse for a bitmap or icon file through the Pictures tab in the Properties dialog box.

Note:

QuickSheet

Web Controls

Web Controls are similar to Mathsoft Controls, but are intended for worksheets created for use with the Mathcad Application Server. They render as standard HTML form controls when displayed in a Web browser. The Properties dialog is used to change values on the Web Controls, but they are not scriptable.