From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Initializing a control array with a certain value

I have 2 arrays, one of them is just an indicator element, the other one is a control element. I want to initialize the controle element with the values from the indicating array. Is there a chance to do that with a local variable?

0 Kudos
Message 1 of 6
(2,977 Views)

Yes.

 

Have you tried?

 

However, if the indicator hasn't been updated yet, what are you going to write to the control? Are you perhaps looking into something like having the control set to a default value, and saving the VI with that control set to its default value?

 

 

Required disclaimer: local variables should be used with care, as they are probably the #1 contributor to sloppy code and race conditions. Don't believe me? Look here: http://forums.ni.com/t5/BreakPoint/Why-some-people-say-Local-Variables-are-bad/td-p/711239

0 Kudos
Message 2 of 6
(2,974 Views)

I just have tried it with a property node, but this seems to be a bad solution, if i want to parse it to a next higher instance, it's not gonna work.

How should I connect the local variable with the control element?

0 Kudos
Message 3 of 6
(2,971 Views)

What do you mean by parsing it to a next higher instance? Please indicate exactly what you are trying to do. Post some VIs if possible.

0 Kudos
Message 4 of 6
(2,967 Views)

Well, I try to explain, I apologize already in advance, english is not my native language.

 

I have an index card with two tabs. The first tab (orginial) is an indicator element (array) and the second tab (editiert) is the control element (also an array).

I generate an array with a certain numbers of lines (control element #lines) which are shown in the indicating array. When I switch from tab "original" to "editiert" I want that this control element is initialised with the values from the indication array. Now I can change these values.

When I switch back to "original" tab and generate new values and go back to tab "editiert" I want that the new values will be shown in the control element.

When I run this sub-vi alone, everything works well. When I start this vi (same FP like the sub-vi) as a sub-vi, this procedure doesn't work like it should.

When switching from tab to tab the values wont be updated.

I attached the vi.

thanks for your effort.

0 Kudos
Message 5 of 6
(2,960 Views)

Though I can't get an exact solution. But after seeing ur VI I can suggest you some code optimization.

Instead of checking the click of a button using dis search array functions and all. You can freely use "Event Structures" thru wich it'll be much easier to handle.

0 Kudos
Message 6 of 6
(2,931 Views)