LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

default value for array size

Solved!
Go to solution

GDay,

 

i have a cluster with some values and an boolean array. I am using the cluster in different VIs, so i saved it as an typedef.

i would like to add a mandatory array size for my 2-dimensional boolean array. how can i afford it?

 

thanks a lot

bemvo

0 Kudos
Message 1 of 7
(3,539 Views)

Hi bemvo,

you can do it in your constant. Create the values you need and store them as default. Additionally you can use the reshape array function in your block diagram.

 

Mike

0 Kudos
Message 2 of 7
(3,536 Views)
Solution
Accepted by topic author bemvo

Storing the values as a default or using the Reshape Array doesn't really perform the action of forcing a mandatory array size. You can't really set a mandatory array size "automatically". A programmer can plop down your typedef on the block diagram, and change the number of rows/columns any way they want, regardless of whether it has default values. Thus, your program has to check this whenever the cluster is being used. Whether or not you choose to generate an error is up to you, depending on what the data means.

 

On a broader note, LVOOP (or similar) can be used for this sort of thing. For instance, if you had an accessor function for setting the array that accessor function can verify the size of the array.

 

You may also be able to do this with XControls, but I'm not sure since I have very little familiarity with those.

Message Edited by smercurio_fc on 07-15-2009 09:18 AM
0 Kudos
Message 3 of 7
(3,527 Views)

smercurio_fc wrote:

...

 A programmer can plop down your typedef on the block diagram, and change the number of rows/columns any way they want, regardless of whether it has default values. Thus, your program has to check this whenever the cluster is being used. Whether or not you choose to generate an error is up to you, depending on what the data means.

 

On a broader note, LVOOP (or similar) can be used for this sort of thing. For instance, if you had an accessor function for setting the array that accessor function can verify the size of the array.

 

You may also be able to do this with XControls, but I'm not sure since I have very little familiarity with those.

Message Edited by smercurio_fc on 07-15-2009 09:18 AM

Why should LVOOP help if the programmer change his restrictions. If someone change the size in the blockdiagram, then he can also change the accessor function. 😉

 

Mike

0 Kudos
Message 4 of 7
(3,523 Views)

MikeS81 wrote:
Why should LVOOP help if the programmer change his restrictions. If someone change the size in the blockdiagram, then he can also change the accessor function. 😉

My point was that it helps to deal with this kind of situation. In other words, never provide a means to access class members directly (i.e., make them private). Instead, provide accessor functions that check the data. 

0 Kudos
Message 5 of 7
(3,520 Views)

Looks like that it is not possible.

 

Im will add some kind of errorhandling for these exceptions.

 

thanks to everybody.

0 Kudos
Message 6 of 7
(3,494 Views)

Hi bemvo,

at which point in your code do you need the fixed array size? Can you give an example?

 

Mike

0 Kudos
Message 7 of 7
(3,492 Views)