08-12-2015 12:16 PM - edited 08-12-2015 12:20 PM
Is there an easy way to change the data type of a control in a VI using scripting? Lets say I have a VI with a scalar string control on the front panel. What is the easiest way to convert that control into a scalar boolean control? If the control is connected to the connector pane I want to preserve that, and preserve any wiring on the BD, references, etc of the old control.
I've looked into it and there are a few options that don't seem to do what I want. I can use the Create From Data Type, and provide a boolean, and create the boolean control, I was hoping I could then select the boolean control, perform a copy, select the string control, perform a paste, and the control would be replaced just like in the IDE if you did it manually. This doesn't work and instead I paste a new copy of the boolean.
There is also a couple of replace functions, but these seem to only work on a style, a path, or a palette string, and not the data type, or another control reference.
Is there an easy method I've missed? Thanks.
EDIT: Okay I can create a new Control VI, save it to a temp path, then use the replace function, providing a path to that temporary control, but is there an easier way?
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-12-2015 02:33 PM
I'm probably missing something, but why is the solution with Replace method not easy enough? (Snippet below, sorry for its dirtiness)
Ok, you have to make some coding for each data type and decide which control you use. But there is no "Generic Boolean Control", just "Push Button", "OK Button", "Round LED", "Square LED"... So any solution would need you to decide what control you will use exactly - even the one with creaing temporary control you described.
08-12-2015 03:36 PM - edited 08-12-2015 03:37 PM
@PiDi wrote:
I'm probably missing something, but why is the solution with Replace method not easy enough? (Snippet below, sorry for its dirtiness)
My data type is not known at run time. What if I have a string control and I want to replace it with an array of a cluster that contains an error and a string? Or an enum? I want the generic solution. I have a control on the front panel, and I want to replace it with the data type found on this terminal, not caring about how it looks on the front panel. All I care about is the interface.
The solution I found is one I partially described in my Edit, which looks like the following and was used in this right click function.
https://decibel.ni.com/content/docs/DOC-43671
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord