Technical Reference > CtAPI Functions > Function Reference > CtAPITrend

CtAPITrend

Provides an interface into the trend archive from external applications, replacing the old CtAPITrend query. For performance improvements, use the TrnQuery function instead.

To establish the query and return the first record, you call ctFindFirst. Then, to browse the remaining records, you call ctFindNext. To access the data of the current record, ctGetProperty is called for each field of the record.

ctFindFirst is called with the following parameters:

The szTableName is the command string for the query. It contains the parameters for the query.

Syntax

CTAPITrend(sTime,sDate,Period,Length,Mode,Tag)

Note: Arguments needs to be comma-separated. Spaces between arguments are supported but not necessary. We recommend no spaces between arguments as they require more processing and take up more space in the query string.

sTime:

The starting time for the trend. Set the time to an empty string to search the latest trend samples.

sDate:

The date of the trend.

Period:

The period (in seconds) that you want to search (this period can differ from the actual trend period).

The Period argument used in the CTAPITrend() function needs to be 0 (zero) when this function is used as an argument to ctFindFirst() for an EVENT trend query.

Length:

The length of the data table, i.e. the number of rows of samples to be searched.

Mode:

The format mode to be used:

Periodic trends

Event trends

Tag:

The trend tag name for the data to be searched.

To simplify the passing of this argument, you could first pass the CTAPITrend() function as a string, then use the string as the szTableName argument (without quotation marks).