LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Activating an array of boolean Controls

In the attached VI, the Array_2 works as expected but Array_1 does not.

 

Of course InArray_2 controls were operated once manually and Saved as such. 

 

But the InArray_1 was not gven any such treatment and so they appear disabled. Being a small array I can do a manual operation to Init the boolean controls but what happens if a I have a large array. How to make the controls active ??

 

(The Indicators were not initialized in both OutArray_1 and OutArray_2.)

 

And more important how does LV permit running the VI when it knows pretty well the Controls are simply dead ??

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 8
(4,659 Views)

Array 1 is empty, thus you're looking at Null values, therefore it looks disabled.

You have chosen to look at the first 8 array values in the form of buttons, and they're all empty. That's expected behaviour.

Replace element requires an existing array.

 

What you want/need to do is Initialize Array by which you can create any size of array with a default value (typically False in the case of booleans).

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 8
(4,648 Views)

@Yamaeda wrote:

Array 1 is empty, thus you're looking at Null values, therefore it looks disabled.

You have chosen to look at the first 8 array values in the form of buttons, and they're all empty.


Of course if I were to use as a standalone VI, then there is no issue in using a Initialize Array with a Boolean element. But my requirement is to use the example which I had earlier posted as a Sub-VI.

 

So even though it always got a proper initialized array for manipulation, the Replace action failed as I never cared to initialize the booleans in Sub_VI. ( I thought dropping a Boolean element into a array container on FP should do.) 

 

I was under the impression that the default state of a Boolean is False. This is a bit of a surprise.   

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 8
(4,641 Views)

@Raghunathan wrote:
Of course if I were to use as a standalone VI, then there is no issue in using a Initialize Array with a Boolean element. But my requirement is to use the example which I had earlier posted as a Sub-VI.

There is no bearing on whether this is a subVI or a top-level VI. If you have an empty array, then operations such as Replace Array Element and Insert Into Array operate on nothing, and therefore give you nothing. There is no inconsistency here.

 

 


So even though it always got a proper initialized array for manipulation, the Replace action failed as I never cared to initialize the booleans in Sub_VI. ( I thought dropping a Boolean element into a array container on FP should do.

 

Dropping an element onto an array container sets the datatype. It does not set the value of the array (i.e., how many elements it contains, and what the value of each element is). Again, this is standard operating procedure in all languages.

 

 


I was under the impression that the default state of a Boolean is False. This is a bit of a surprise. 

 

There is no surprise - you are not understanding the point. The default value of a Boolean value is whatever you want it to be - true or false. You can place a false or true Boolean constant on the block diagram.  The default value of an array is an empty array, regardless of the datatype of the element in the array. That's what you are misunderstanding.

 

 

0 Kudos
Message 4 of 8
(4,629 Views)

Your code is also overly complex. To update with a constant like you are doing now, just do as below:

 

0 Kudos
Message 5 of 8
(4,617 Views)

My text based knowledge is rusting so i'll pseudo code, but your Array_1 is similar to:

bool[] Array_1

 

Then you do a:

Array_1[7] = True

 

What is the result? Undefined, there is no element 7.

 

The fact that you have prepared a indicator to look at the first 8 elements doesn't change the fact that there isn't 8 elements.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 8
(4,612 Views)

@smercurio_fc wrote:

.....

 

 You can place a false or true Boolean constant on the block diagram. 

......


The confusion was due to that only. The similar assumption that a boolean control when dropped into an array will be False logic , tripped.

 

And to add to the confusion, when you open the properties of the dropped boolean, it says Enabled. It takes a while and few knocks on  the head in the forum to understand that the boolean has a null state.

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 7 of 8
(4,594 Views)

It is an ARRAY that has a null state. Nothing at all to do with a Boolean.

0 Kudos
Message 8 of 8
(4,580 Views)