Cicode Programming Reference > Cicode Function Categories > Trend Functions Introduction > TrnExportDDE

TrnExportDDE

Exports trend data via DDE. The data is set at the specified Time and Period, and listed from earliest to latest. Any gated or invalid data is written as 0.0. Data is stored as a grid, with each row time-stamped. The first column/field is the date, followed by the time, followed by the tags 1 to 8.

You can use the DDEMode argument to make the output more useful. For example; to paste the data into Excel, use DDEMode 2 for CSV format. If you use DDEMode 1, data will be put into the user's spreadsheet as text.

Note: If you're using this function to export trends by using event numbers, you need to specify a valid event number in the Time argument, rather than a time.

Syntax

TrnExportDDE(sApplication, sDocument, sTopic, Time, Period, Length, Mode, DDEMode, sTag1 ... sTag8, iDisplayMode1 ... iDisplayMode 8)

sApplication:

The application name to export the data.

sDocument:

The document in the application to export the data.

sTopic:

The topic in the application to export the data. Be aware you may have to use a special topic format to make the data export correctly. See your application documentation for details; For example with Excel you need to specify the matrix of rows and columns as "R1C1:R8C50" depending on the size of the data.

Filename:

The name of the destination path and file.

Time:

The starting time for the data being exported.

Period:

The period (in seconds) of the entries being exported. (This period can differ from the actual trend period.)

Length:

The length of the data table, that is The number of rows of samples to be exported. for example if you put the length as 12, and you declare two tags to be exported, you get a grid with 12 rows of samples. Each row has values for each of the two tags making a total of 24 samples.

Mode:

The format mode to be used:

Periodic trends

1 - Export the Date and Time, followed by the tags.

2 - Export the Time only, followed by the tags.

4 - Ignore any invalid or gated values. (This mode is only supported for periodic trends.)

8 - The time returned will have millisecond accuracy.

Event trends

1 - Export the Time, Date and Event Number, followed by the tags.

2 - Export the Time and Event Number, followed by the tags.

8 - The time returned will have millisecond accuracy.

DDEMode:

The format for the data being exported. CSV format allows the application to separate the data into each individual element, however not every application will support this mode. See you applications documentation for details.

1 - Text (default)

2 - CSV

sTag1 ... sTag8:

The trend tag names for the data being exported. Tag names longer than 10 characters will be truncated, as the standard DBF field format is 10 characters.

iDisplayMode1 ... iDisplayMode8:

The Display Mode parameters allow you to enter a single integer to specify the display options for a trend (for a maximum of eight trends).

To calculate the integer that you should enter for a particular trend, select the options you wish to use from those listed below, adding their associated numbers together. The resulting integer is the DisplayMode parameter for that trend.

By default, this argument is set to 3 (see the details for options 1 and 2 below).

Invalid/Gated trend options:

0 - Convert invalid/gated trend samples to zero.

1 - Leave invalid/gated trend samples as they are.

Invalid and gated samples that are not converted to zero will appear in the destination file as the string "na" (for invalid) or "gated".

Ordering trend sample options:

0 - Order returned trend samples from newest to oldest.

2 - Order returned trend samples from oldest to newest.

Condense method options:

0 - Set the condense method to use the mean of the samples.

4 - Set the condense method to use the minimum of the samples.

8 - Set the condense method to use the maximum of the samples.

12 - Set the condense method to use the newest of the samples.

Stretch method options:

0 - Set the stretch method to step.

128 - Set the stretch method to use a ratio.

256 - Set the stretch method to use raw samples.

Gap Fill Constant option:

n - the number of missed samples that the user wants to gap fill) x 4096.

Options listed in each group are mutually exclusive.

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

TrnExportCSV, TrnExportClip, TrnExportDBF

Example

TrnExportDDE("Excel", "data.xls", "R1C1:R61C4", TimeCurrent(), 1,
60, 2, 2, "Feed", "Weight");
/* Export the last 60 seconds of data from the trend tags Feed and Weight into Excel at R1C1:R61C4 in CSV formats */

See Also

Trend Functions