07-15-2009 08:50 AM
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
Solved! Go to Solution.
07-15-2009 08:57 AM
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
07-15-2009 09:16 AM - edited 07-15-2009 09:18 AM
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.
07-15-2009 09:22 AM
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
07-15-2009 09:28 AM
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.
07-16-2009 10:16 AM
Looks like that it is not possible.
Im will add some kind of errorhandling for these exceptions.
thanks to everybody.
07-16-2009 10:17 AM
Hi bemvo,
at which point in your code do you need the fixed array size? Can you give an example?
Mike