Preserve Run-Time Class Function

LabVIEW 2018 Help


Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)


LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

Owning Palette: Cluster, Class, & Variant VIs and Functions

Requires: Base Development System

Checks at run time whether object in is of the same class as, or is a child class of, target object.

Use this function on the block diagram of a subVI when you want to guarantee that LabVIEW downcasts a LabVIEW class output of the subVI node to the same class type as a LabVIEW class input when the subVI receives a child class of the expected input type.

Details  Example

target object—is the object whose class you want to compare to the class of object in.
object in—is the object you want LabVIEW to downcast automatically.
error in describes error conditions that occur before this node runs. With the following exception, this input provides standard error in functionality.

This node runs normally even if an error occurred before this node runs.
object out—is the same as object in. If the target object is incompatible with object in, the function returns an error and the data value of object out is of the same wire type as target object.
error out contains error information. This output provides standard error out functionality.

Preserve Run-Time Class Details

Use this function in VIs that meet the following criteria:

  • The VI accepts a LabVIEW class as an input and returns the same LabVIEW class as an output.
  • You want to call the VI as a subVI.
  • You want to guarantee that the output class type of the resulting subVI node always changes to match the input class type when a child class is wired as an input.

For many subVI nodes that accept and return the same LabVIEW class, LabVIEW automatically downcasts the output class when you wire a child class to the class input. Those subVIs do not require you to use this function on their block diagram.

However, if it is impossible for LabVIEW to verify that the class type does not change across the block diagram of the subVI, LabVIEW does not automatically downcast the output class of the subVI node. In these cases, if you have additional knowledge that guarantees that the class type does not change across the block diagram of the subVI, you can use this function to downcast the class immediately before returning it from the subVI. Because this function always returns an object of the same type as target object, LabVIEW recognizes that it can downcast the returned class to that type. Therefore, this function notifies LabVIEW that it is safe to downcast the class output of the subVI node to match the input class type.

Related Information

Casting LabVIEW Classes

Example

Refer to the Preserve Run-Time Class.lvproj in the labview\examples\Object-Oriented Programming\Preserve Run-Time Class directory for an example of using the Preserve Run-Time Class function.

WAS THIS ARTICLE HELPFUL?

Not Helpful