TrnSetTime
- Last UpdatedFeb 02, 2024
- 2 minute read
Sets the end time and date of a trend pen.
If you set a time less than the current time, the trend display is set to historical mode and samples taken after this time and date will not be displayed.
If you set the time to the current time, for example by using the TimeCurrent or TrendZoom Cicode functions, the trend is displayed in real-time mode and samples after this date and time will display.
Note: The end time specified for a trend object may automatically align with the display period that is used. To stop this occurring, you can use the TrnSetDisplayMode function by setting the DisplayMode parameter to 16777216 (samples will no longer synchronize to the nearest display period). You can set this as a default for a page by configuring the function as an On page shown event in the Page Properties (see Page Properties - Events).
Syntax
TrnSetTime(nAN, Pen, Time)
AN:
The AN where the trend is located, or:
-1 - All trends on the current page
0 - The trend where the cursor is positioned
Pen:
The trend pen number:
-1 - All pens
0 - The pen currently in focus
1...8 - Pen1. . .Pen8
Time:
The end time and date of the trend. Samples taken after this time and date will not be displayed. Set to 0 (zero) to set the trend to the current time (real-time mode).
Return Value
0 (zero) if successful, otherwise an error code is returned.
Related Functions
Example
TrnSetTime(20,1,TimeCurrent()-60*30);
/* Sets Pen1 to 30 minutes before the current time (30 minutes ago). */
TrnSetTime(20,1,0);
/* Sets the trend to real-time mode. */