From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmably select item from combobox (strings and values[]).

I tried use  property node "Value" of combobox, but it good for "strings[]", not "strings and values[]".

 

Task: change combo box in interface when input data from Python node.

0 Kudos
Message 1 of 10
(1,222 Views)

Hi Lugaro,

 


@Lugaro wrote:

I tried use  property node "Value" of combobox, but it good for "strings[]", not "strings and values[]".


What have you tried? (Mind to attach code? LV2017 preferred!)

Where did you fail?

What's wrong with using "strings[]"? Which "value" did you set?

Is there a typedefinition involved?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(1,219 Views)

Now I cant give code.

 

Why not string[]: 

User must see in combo box "COM1: Serial USB" and "COM10: Virtual port". Combo box must return only "COM1" or "COM10".

So: STRING "COM1: Serial USB" , VALUE  "COM1".

 

 

Where I fail: 

If I make "value"  - "COM1: Serial USB" . Return combobox value is "COM1:". Need "COM1".

 

Lugaro_0-1632393602836.png

 

 

 

0 Kudos
Message 3 of 10
(1,197 Views)

Hi Lugaro,

 

first you should remove that glaring race condition in your code!

Reading the combobox in parallel to writing its properties will most likely give unexpected results...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(1,192 Views)

The little arrow in the string output that you have circled is and indication that there is more data than it is showing.  Expand the box out to be as long as the one that has the info on it and you should see everything.

0 Kudos
Message 5 of 10
(1,163 Views)

@GerdW wrote:

Hi Lugaro,

 

first you should remove that glaring race condition in your code!

Reading the combobox in parallel to writing its properties will most likely give unexpected results...


Oh it's worse than "most likely give unexpected results".  It can give 'expected results' most of the time, even for years; then for no "apparent" reason, start giving unexpected results.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 10
(1,155 Views)

To add into the what could go wrong in parallel code.  Every time you make a change, even a minor one, to your code it gets recompiled. The order which parallel items end up happening can be changed depending on the compile operation. Thus it is aways best to have explicit order of operation. 

 

A single frame sequence with all of the stuff that you expect to happen before the loops starts with something from it being wired to the edge of your main loop is how I handle this.  It does not have to be used in the main loop just wired up to it.

0 Kudos
Message 7 of 10
(1,151 Views)

@Tom_Powers wrote:

To add into the what could go wrong in parallel code.  Every time you make a change, even a minor one, to your code it gets recompiled. The order which parallel items end up happening can be changed depending on the compile operation. Thus it is aways best to have explicit order of operation. 

 

A single frame sequence with all of the stuff that you expect to happen before the loops starts with something from it being wired to the edge of your main loop is how I handle this.  It does not have to be used in the main loop just wired up to it.


No, it's not "aways best to have explicit order of operation".  Rules that say 'Always this..'  or 'Never that...'  are brainless.  What's really best is to use your brain to figure out what to do instead of relying on some simplistic rule.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 10
(1,143 Views)

@Lugaro wrote:

 

Why not string[]: 

User must see in combo box "COM1: Serial USB" and "COM10: Virtual port". Combo box must return only "COM1" or "COM10".

So: STRING "COM1: Serial USB" , VALUE  "COM1".

 

 

Where I fail: 

If I make "value"  - "COM1: Serial USB" . Return combobox value is "COM1:". Need "COM1".


The race condition is of course a glaring problem. There's also another thing I think... When using "Strings And Values []" property, the String is what you want to be displayed in the combo box and the Value is what the combo box actually outputs. If you also change the value of the combo box with a Value or Value Signaling property node or a local variable, it messes that all up by writing both the string and value. Whereas if the combo box value is chosen using the dropdown, the correct output will result ("3" in this case).

Spoiler
FireFistRedhawk_0-1632404591195.png

 


 

 

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 9 of 10
(1,137 Views)

@Lugaro wrote:

Now I cant give code.

 

Why not string[]: 

User must see in combo box "COM1: Serial USB" and "COM10: Virtual port". Combo box must return only "COM1" or "COM10".

So: STRING "COM1: Serial USB" , VALUE  "COM1".

 

Where I fail: 

If I make "value"  - "COM1: Serial USB" . Return combobox value is "COM1:". Need "COM1".


Why not just use Value with the long string and cut the string at colon?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 10
(1,114 Views)