LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange array of ctl behaviour

Solved!
Go to solution

Why do I have to change a value in an array of .ctl before the current index gets usable?

If I dont change a value after startup the default values arent used.

 

 

0 Kudos
Message 1 of 11
(1,619 Views)

Hi,

 


@Quiztus2 wrote:

Why do I have to change a value in an array of .ctl before the current index gets usable?


Because your array is empty. Indexing an element from an empty array just gives you default values…

Best regards,
GerdW


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

I have overwritten the default values in the ctl's elements. That is why Labview displays these values, but forwards the types(uint,int) default values instead. This makes hardly sense.

0 Kudos
Message 3 of 11
(1,606 Views)

Please downconvert your example for LV2020 (File->Save for previous)…

 


@Quiztus2 wrote:

I have overwritten the default values in the ctl's elements.


A typedefinition (ctl) only defines the type, but not the value…

Best regards,
GerdW


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

@Quiztus2 wrote:

This makes hardly sense.


Yes it does. I cannot look at your code because the version is newer than what I have, but your diagram picture certainly raises a lot of eyebrows.

 

  • Indexing out an element that does not exist gives you the default value for the datatype, not the default value for the element. A default value is a property of the terminal (control or indicator), not of the data in the wire. If would be really confusing to return real-looking data when indexing out of bounds.
  • Why do you read from a local variable instead of the array terminal?
  • What's the purpose of the error wire?
  • Why do you need a greedy loop that cannot be stopped?
  • You can easily add a tiny little bit of code that returns something specific if you try to get an element that does not exists. Instead of data, you should return an error of course. You can easily make the array have a default values where the size is not zero.
0 Kudos
Message 5 of 11
(1,577 Views)

For me it is a secret how one can initialize an array with a ctl's elements default values programatically.

0 Kudos
Message 6 of 11
(1,558 Views)

Get rid of the local.  You don't need it the terminal is right there and unwired.

 

Get some type of timing in that loop and a stop condition!  If you want the vi to respond to user input....use a value change event case.

 

The control is not behaving strangely,  the programmer is!

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 11
(1,557 Views)

@JÞB wrote:

Get rid of the local.  You don't need it the terminal is right there and unwired.

 

Get some type of timing in that loop and a stop condition!  If you want the vi to respond to user input....use a value change event case.

 

The control is not behaving strangely,  the programmer is!

 


The more experience you have, the more likely that what you want the program to do and what you tell it to do will converge.  Hopefully.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 11
(1,540 Views)

On a side note, your question does have some validity!

 

 Have a look at my 10 year old idea and its comments here. 😄

 

IdeaArrayDefaultHandling.png

Message 9 of 11
(1,537 Views)
Solution
Accepted by topic author Quiztus2

@Quiztus2 wrote:

For me it is a secret how one can initialize an array with a ctl's elements default values programatically.


One possibility:

 

altenbach_0-1658243090478.png

 

 

0 Kudos
Message 10 of 11
(1,522 Views)