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

TrnExportClip

Exports trend data to the Windows Clipboard. 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 ClipMode argument to make the output more useful. For example, to paste the data into Excel, use ClipMode 2 for CSV format. If you use ClipMode 1 or 3, the default paste menu option causes data to be pasted into the user's spreadsheet as text. If you use ClipMode 3, use the Paste Special option to paste the required format. Please be aware that not all packages support multiple clipboard formats in this way.

Syntax

TrnExportClip(Time, Period, Length, Mode, ClipMode, sTag1 ... sTag8, iDisplayMode1 ... iDisplayMode 8)

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. (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.

ClipMode:

The format for the data being exported.

1 - Text

2 - CSV

You can add these modes for a combination of formats.

sTag1 ... sTag8:

The trend tag names for the data being exported.

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.

Display as Periodic options:

0 - Display according to trend type.

1048576 - Display as periodic regardless of trend type.

Return Value

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

Note: If 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.

Related Functions

ClipSetMode, TrnExportCSV

Example

TrnExportClip(TimeCurrent(), 2, 60 * 60/2, 2, 3, "Feed",
"Weight");
/* Export the last hour of data from the trend tags Feed and Weight to the clipboard in both Text and CSV formats. Be aware that the 60 * 60/2 is a decomposed way or writing 1800, which is the number of 2 second samples in 1 hour. */

See Also

Trend Functions