2.3. Accessing and Copying Point Values

Cascade DataHub points may take on one of three types:

Since the type may change during the life of a point, care must be taken to ensure that the appropriate value is used in a given situation. This can be simplified by using the accessor functions PT_PointString, PT_PointInt and PT_PointReal, which will perform a best-guess conversion of the point type to the type requested. The PT_PointString function will also format the point value according to a printf-style format directive. The value of a point really includes attributes like its timestamp, confidence factor and security, so it is better to copy the point value using the PT_PointCopyValue function, which will copy all related information into the destination point. If the type of the point is PT_TYPE_STRING, then the point value will be allocated on the heap. In addition, if the destination point is an existing point of type PT_TYPE_STRING, then its current value will be freed using the free() C library call.