Change parent data type by script

Is there a way to change the parent data type dynamically?

I have the same set of tag name and description used in graphics, but one set of tags is from OPC, the other one is from memory.

If I can dynamically change the parent data type, I can then use the same page for both tag sets.

Datatype conversions are typically trivial, but I'm not sure what you are asking. What is the parent, and what is the child? Where do they live? How do these tags come into play?

So the goal here is to use the same page for different things.
Now the question becomes "How can I use the same page for thing A and thing B ?"

What are thing A and thing B ?
How do you want to use them ?
What does the page do ?

Simply don't use UDT parameters in your GUI. Pass a tagpath parameter to your reusable UI elements. Then use indirect binding within the UI to the specific sub-elements of the given tagpath.

With that approach, you can reuse the UI element no matter what the tagpath points at, as long as it has the same-named subelements. Whether UDT instances from many different actual UDT definitions, or simply a folder of tags with the same names and types as a UDT, the UI won't care and will function correctly. You can even support optional tag elements by using overlay opt-out on selected bindings and testing their qualities.

UDTs are great for organizing and maintaining large numbers of tags. They terrible for use as parameters.

1 Like