# Basic DDE Operations

If you are using Windows 95/98/NT/2000 as your operating environment, Dynamic Data Exchange (DDE) is the mechanism for creating links between your models and other applications. The process is essentially the same as that for Copy/Paste. The communication linkage is between a server, the file which generates the data, and a client, the file which will receive the data. The next two sections detail the Import/Export process using DDE and will be followed by a discussion of general principles governing the process.

## The Model as Server

Exporting Data Using DDE: Creating a link that exports data from a model is a simple process. The link will be created from a table in your model. The process of creating the DDE link parallels the process of Copying and Pasting data.

To create a link to export data from your model, you will need to:

- Set up a Table Pad page in the model with the desired variables and format (see Chapter 6 for details on defining and formatting tables) - the Table is the only locus in the software for exporting via a link. Run the model.

- Save both the model file and the file in the other application. The link will use the file names to describe the connections.

- Click on the column header to select the column of data to be exported (hold down the shift key to select multiple contiguous columns or the control key to select noncontiguous columns). Figure 8-1 illustrated this process.

- Choose Copy from the Edit menu - the data will automatically be stored in the clipboard included in your System.

- Navigate to the file which is to receive the data. Follow the directions for Special Pasting into the recipient application - usually a Paste Special or Paste Link from the Edit menu.

If you subsequently open a file which contains links to a model file, you must open the model file first. The software will help you reestablish the links.

## The Model as Client

Importing Data Using DDE: The process of creating a DDE link parallels the process of Copying and Pasting data. To create the link from another application into your model, you will need to:

- Save both the model file and the file in the other application (make sure you verify the application supports DDE). The link will use the file names to describe the connections.

- Copy the data set from another application following the directions available with that application. The data will automatically be stored in the clipboard included in your System.

- Switch to your model and open the variable dialog which is to receive the data.

- Highlight the Output column in the graphical function or the contents of the equation box and use the key command control V. A secondary Paste Special dialog will appear. Choose Paste Link and click OK to deposit the data. [Note: Copy and Paste are grayed out in the Edit menu when a Variable dialog is opened, necessitating the use of key commands.)

If you subsequently open a model file which contains links, the software will help you to reestablish links and open the server file.

Once the link is created, a thick rectangle will be drawn around the equation box or output column which contains the link. Once you have created a DDE link within a particular entity, it is no longer possible to edit any data contained within the entity. A small 'x' will appear on the entity to indicate that a DDE link exists. If the link is within an Output column in a graphical function, you no longer will be able to type data into the column or sketch in curves using the X-Y grid.

When you exit the dialog of an entity that has a DDE link by pressing the Cancel button, you will be given the option of breaking the DDE link.

Formats for DDE Links into your model: Before establishing a link into a model variable, you must be familiar with where you can make the link and you must ensure that the data is appropriate to the location. The rules for each DDE recipient are listed here. For special rules that apply to links into arrayed variables, see the next section.

1) For successful linking into your model, links can contain numbers only - no graphics or equations. See the previous section for directions for setting up a link from a model.

2) A graphical function created within flows or converters can hold up to 1500 data points (numbers only). See Chapter 4 for details on creating graphical functions. The link will be established with the Output column on the top, right side of the dialog. You must select the entire column. To select the entire column all at once, click once on the word Output at the top of the column. The column will highlight, as was illustrated in Figure 8-2.

3) Reservoirs and Ovens, and flows and converters without inputs, can be recipients of a link containing a single constant.

4) Queues and Conveyors can be the recipient of single or multiple constants for their initial values, but multiple numbers must be separated by commas.

[Note: If the data is being linked from a spreadsheet, a column of commas, one cell shorter than the data, can be created alongside the column of data as seen here. Copying them together will bring the data in the necessary format.]

If the data does not conform to these requirements, when you attempt to click OK to exit the dialog, the erroneous data will become highlighted, and you'll encounter an error message such as the one shown in Figure 8-3. To fix the problem, simply click the Cancel button to break the link. Then return to the data server to correct the format. |

Figure 8-3 Linked Values in Incorrect Format

Managing DDE Links into your Model: Once you have created links into your model, it can be exceedingly helpful to manage those links. You may want to destroy a link, for example. Or, in other cases, you may simply want to have a single list showing all links into your model. The Edit Links dialog, found under the Model menu, provides a plethora of tools for managing the DDE links into your model. See the discussion of Edit Links for details.