LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

typedef array does not auto-update

Hello,

 

I'm trying to create a strict typedef array that contains an ENUM control. I notice that if I add or delete items from the ENUM, then the control and control constants will update accordingly. However, if I increase the size of the array (insert or remove elements), and save the control as a strict typedef, the front panel control and its associated constant will not update to reflect the changes. Is there a way to do this? If the size of my strict typedeft control changes I would like to find a way to update the constants in my program to reflect this change.

 

Thanks!

0 Kudos
Message 1 of 10
(6,220 Views)
The number of elements in the array is part of the value of the array, not its definition. Think of a scalar control. If you have a typedef and drop a constant for it on your BD and change it to the value 3, but later on redefine your typedef (let's say you add a decoration, or even change it's default value from 0 to 10), the constant will update, but the value of 3 isn't going to change to 4. It is the same way with an array. The number of elements defined in an array as well as what the values that each of those elements are, are all a part of the value of the typedef'd array. They won't get changed by updating the typedef.
Message 2 of 10
(6,213 Views)

Ravens Fan,

 

oh, I see. That makes sense. I'm still looking for an efficient way of wiring case statements. I thought I could do so by using a constant variable (array of typedef enum's). I have many case statements scaterred throughout multiple vi's and would like a quick way of updating them should the size of the array and / or # of items in the typedef change.

 

 

0 Kudos
Message 3 of 10
(6,197 Views)
Changing the size of the array would not provide any help in updating case structures. As for changing the enum typedef if the case structures are not set to have a default case then you would get broken arrows indicating you don't have a case element for all enum elements. If, on the other hand, the case structure has a default case, then you'd get no broken arrows.
0 Kudos
Message 4 of 10
(6,173 Views)
I apologize, my questions were not addressed clearly. Attached is the program I am trying to build.
0 Kudos
Message 5 of 10
(6,149 Views)
Build into what? I'm not sure where you're going with it. As it is, I don't understand the purpose of the case structure in the first place - it's hard-wired to a constant. Is it supposed to be wired to the string? Is this intended to be a subVI? If so, what is the output?
0 Kudos
Message 6 of 10
(6,131 Views)

If you want to update the array constant based on changes you made to the typedef of the array,

 

1.  Update your typedef control.

2.  Drop a new control of that onto your front panel.

3.  Go to the block diagram, right click on its terminal, select Change to Constant.

4.  Delete your old constant and wire it into the new one.

 

If you have to update consants to be the same thing in numerous locations, then you are better off creating a subVI that has only a single output and sends out the constant.  That way if you need to change the constant, you only have to update it once inside the subVI instead of numerous other locations.

Message 7 of 10
(6,129 Views)

Sorry to resume message which are resting deep into the server, but after banging my head for some 30 minutes trying to find out what I was doing wrong, I realized that maybe this is just way Labview behaves.

So my issue's just the one of this topic. I find somehow odd that you don't get that value updated, or maybe there should be an option to make the typedef even more strict and having the values updated.

Making a VI that spits out the constant value isn't a valuable option because: you don't immediately see the values, and the typedef is used is a cluster which is another typedef itself, so there's no way to get the values from a vi, if I  am not wrong. 

I am wondering if a simple class would solve this issue. The values would not immediately show, but at least the values would be inherited by other classes which embed the origin string array.

But I am naive at using classes, so I don't know is it will be a dead end way. 

Any comment ?





0 Kudos
Message 8 of 10
(5,059 Views)

Yep. 

Basically using a class does the trick. 

But IMO it's like shooting a fly with a gun.

The trick is simple: I created a class, with a string array inside, a just a property which reads the array.

If I update the array value (AND DO "make current value default" otherwise you'll be lost again), than all the class istances do gove out the updated value.

And the class just created can be inserted as a member control in another class (and still give out updated values).

 





0 Kudos
Message 9 of 10
(5,046 Views)

@Runawaycode wrote:

Sorry to resume message which are resting deep into the server, but after banging my head for some 30 minutes trying to find out what I was doing wrong, I realized that maybe this is just way Labview behaves.

So my issue's just the one of this topic. I find somehow odd that you don't get that value updated, or maybe there should be an option to make the typedef even more strict and having the values updated.

Making a VI that spits out the constant value isn't a valuable option because: you don't immediately see the values, and the typedef is used is a cluster which is another typedef itself, so there's no way to get the values from a vi, if I  am not wrong. 


Please attach a simplified version of your VIs, so we get a better idea what you are trying to do.


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 10 of 10
(5,025 Views)