LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simplify code

Solved!
Go to solution

Hello everyone. 

I am working on project for developing RF- measurement system. my code working very fine. but there is one of the cases in the case structure I feel it became mess of wires specially from stuff related to controls disable and enable property node as shown in the attached picture. and I have a VI in that case very very important to do the generators setting for different harmonics so the controls going to it to many as shown in the same picture. I asking if there is another I can do to simplify this code without effecting its work. I wish if there is one of you could help me. I will be really appreciated.  

0 Kudos
Message 1 of 8
(3,522 Views)
Solution
Accepted by topic author thoalfukar

Hi thoalfukar,

 

instead of using a lot of single property nodes you could use an array of control references and a FOR loop to set them dis-/enabled…

 

Personal opinion:

I don't like VIs where the labels of property nodes and control terminals are ALL hidden! Such behaviour makes it hard to understand the block diagram of such VIs…

Maybe there's a reason to obfuscate your code but how can you tell WHICH controls are en-/disabled?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(3,514 Views)
Solution
Accepted by topic author thoalfukar

Pass the array of references to a subVI and enable/disable them there, so that the code can be reused.  I don't use the disabled option because IMO, it's not disabled unless it's grayed out.  But that is a personal preference.

Enable Disable Controls_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 8
(3,488 Views)

Thanks for your kind reply, 

regarding to the question, I know which controls should be enabled and which should be disabled in this case. 

Regarding to your solution, many thanks it is a good idea i didn't think about it, but If I use array of reference I need to build that array and to build it I need very long list of references which end up with the same problem!

Regards

Thoalfukar Husseini

0 Kudos
Message 4 of 8
(3,473 Views)

@thoalfukar wrote:

Thanks for your kind reply, 

regarding to the question, I know which controls should be enabled and which should be disabled in this case. 

Regarding to your solution, many thanks it is a good idea i didn't think about it, but If I use array of reference I need to build that array and to build it I need very long list of references which end up with the same problem!

Regards

Thoalfukar Husseini


You may know which controls, now, because you're working on it.  But will you know a year or two from now when you revisit this code?  Or if someone else (like someone on the forums helping you) know which of those nodes goes to which node?  No.

 

If you were programming in a text based language, would you name all your variables A, B, C, D, E,.... or give them a more meaningful, descriptive name?

0 Kudos
Message 5 of 8
(3,466 Views)

@thoalfukar wrote:

Thanks for your kind reply, 

regarding to the question, I know which controls should be enabled and which should be disabled in this case. 

Regarding to your solution, many thanks it is a good idea i didn't think about it, but If I use array of reference I need to build that array and to build it I need very long list of references which end up with the same problem!

Regards

Thoalfukar Husseini


See here where I posted about a GUI controller that allows me to touch the GUI from a sub-VI.

 

Back in the day...

 

Spoiler

 

Of LV 5.1 there where no property nodes but rather attribute nodes that HAD to be located on the diagram of the VI that contained the controls. large applications with any degree of enhanced look and feel where huge! I swear that the ugliest diagrams you see posted by NI as examples of bad code where developed in LV 5.1 or earlier.

 

I was very excited when I learned that using property nodes in a sub-VI was possible because it let me push down dirty little distracting details into sub-VI where they belonged.

 

 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 8
(3,457 Views)

hi, 

could you tell me how you generate the array of references ? 

do you run the vi and then change it to control

0 Kudos
Message 7 of 8
(3,380 Views)

Hi  thoalfukur,

 

You get an array of all control references using a property node of the VI frontpanel..

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(3,374 Views)