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


Writes trend tag data from a table to the trend logging system (starting at the top of the table, and continuing to the bottom). Each value is written with a time and date, as specified by Period. If Period differs from the trend sampling period (defined in the Trend Tags database), the trend's sample values will be calculated (averaged or interpolated) from the tabulated trend data.

The user needs to have the correct privilege (as specified in the database), otherwise the data is not written.

This function is a blocking function. It will block the calling Cicode task until the operation is complete.


TrnSetTable(Tag, Time, Period, Length, Table, Milliseconds [, ClusterName] )


The trend tag enclosed in quotation marks "" (can be prefixed by the name of the cluster that is ClusterName.Tag).


The time and date (long integer) to be associated with the first value in the table when it is set. Once you have entered the end time and date (Time), set period (Period), and number of trend tag values to be set (Length), the start time and date will be calculated automatically. For example, if Time = StrToDate("18/12/96") + StrToTime("09:00"), Period = 30, and Length = 60, the start time would be 08:30. In other words, the first value from the table would be set with time 9am, and the last would be set with time 8.30am (on December 18, 1996).

If this argument is set to 0 (zero), the time used will be the current time.


This will be the interval (in seconds) between trend values when they are set (that is it will be the perceived sampling period for the trend). This period can differ from the actual trend period. Set to 0 (zero) to default to the actual trend period.


The number of trend values in the trend table.


The table of floating-point values in which the trend data is stored. You can enter the name of an array here (see the example).


This argument allows you to set the time of the first sample in the table with millisecond precision. After defining the time and date in seconds with the Time argument, you can then use this argument to define the milliseconds component of the time.

For example, if you wanted to set data from the 18/12/96, at 9am, 13 seconds, and 250 milliseconds you could set the Time and Milliseconds arguments as follows:

Time = StrToDate("18/12/96") + StrToTime("09:00:13")
Milliseconds = 250

If you don't enter a milliseconds value, it defaults to 0 (zero). There is no range constraint, but as there are only 1000 milliseconds in a second, you should keep your entry between 0 (zero) and 999.


The name of the cluster in which the trend tag resides. This is optional if you have one cluster or are resolving the trend via the current cluster context. The argument is enclosed in quotation marks "".

Return Value

The actual number of samples written. The return value is 0 if an error is detected. You can call the IsError() function to get the actual error code.

Related Functions



REAL TrendTable1[100];
/* Defines an array of a maximum of 100 entries. Assume that TrendTable1 has been storing data from a source. */
/* A set of 10 trend data values are set for the OP1 trend tag. */

See Also

Trend Functions