LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI Scripting - replace class constant

Solved!
Go to solution

Hello,

 

I need to replace class constant via VI Scripting on Block Diagram.

For Controls on FP it is very easy using dedicated method:

pawhan11_0-1578863677196.png

For constant there is nothing to get class name that constant points to, I need to get class path to replace it with something new. I expected there will be something in typedef fields but they are empty.

pawhan11_2-1578863932710.png

I could use terminal to get default class data but that will not work when constant is inside cluster or arrays:

pawhan11_3-1578864062444.png

 

Another idea was to change to control using:

pawhan11_1-1578863754836.png

then do conversions that are required  and convert back to constant. But I can not find a way to convert control to constant in VI scripting.

 

Can Anyone help?

0 Kudos
Message 1 of 3
(2,422 Views)
Solution
Accepted by topic author pawhan11

Well, you don't need a dedicated method for class constants. The GObject class had a Replace method which takes a path, and this works on constants.

 

Also, instead of using the Terminal property to get the data type, you can use the Value property, which will work on nested constants.

 

Depending on how your code works, you might also be able to use the Traverse for GObjects VI and tell it that you want class constants, so that you don't need to check each constant to know if it's a class.


___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(2,360 Views)

Thanks, works as expected! 

0 Kudos
Message 3 of 3
(2,339 Views)