LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Control Data Type Scripting

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?

0 Kudos
Message 1 of 3
(4,001 Views)

I'm probably missing something, but why is the solution with Replace method not easy enough? (Snippet below, sorry for its dirtiness)

replacer.png

 

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.

Message 2 of 3
(3,963 Views)

@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

 

Replace Control Data Type_BD.png

Message 3 of 3
(3,931 Views)