LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Block user from adding elements to an array

How can I stop a user from adding elements to an array, while allowing him to edit the elements already there?
The normal functionality seem to be that you can access an empty array element and then just edit one of the items, and voila you have another element. Not good!
0 Kudos
Message 1 of 12
(3,926 Views)

Hi Rodnebb,

you can monitor the Array change in an Event Structure and delete inserted items or show a warning to the operator.

Mike

0 Kudos
Message 2 of 12
(3,924 Views)
Hi Rodnebb,

you can limit the array in your code using an "Array Subset" function with fixed size.
You should also forbid the context menu of the array control, as the user can select "add elements" here too (LV8+: right-click the array->advanced->run-time shortcut menu).
Or you catch the right mouse button clicks on the control (using an event structure)...
You can also hide the index display of the array, so the user can't access empty cells easily.

And you shouldn't show empty elements on the front panel, as this always will attract the user to click & play! Smiley Wink


Message Edited by GerdW on 01-17-2008 01:42 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 12
(3,923 Views)

Ok, but no direct, hard way of hindering data entry, just a lot of workarounds?

I can check number of elements - or use array subset, good suggestion - but this isn't very elegant.... And, how do I block the user from seeing empty elements? I need to use scroll bar and the index to show the user which element he's working on. (I have one array element pr. device that I control)

0 Kudos
Message 4 of 12
(3,917 Views)

Hi

yes i think there is no direct way to block insert data. But i think the way with an event structre is very elegant. To not show empty elements you can size the array to the size of number of elements. there exist a property for it.

Mike



Message Edited by MikeS81 on 01-17-2008 06:56 AM
0 Kudos
Message 5 of 12
(3,913 Views)

Hi,

In this thread i limited the number of elements displayed for a predefined value, but im sure it could be used for a variable number of elements with a little more coding.

http://forums.ni.com/ni/board/message?board.id=170&message.id=265806#M265806

Craig

LabVIEW 2012
0 Kudos
Message 6 of 12
(3,906 Views)

Great Craig, this looks like it.

Another question - now that I have this fancy code that manipulates the arrays, how do I get it off my block diagram? I'll use this code for several arrays and I'd like to put it into a sub-vi. Any suggestions how this is best done? Shall I just send the references down, or is there a better way?

 

0 Kudos
Message 7 of 12
(3,888 Views)
Hi rodnebb,

first: don't use spaces in filename - when downloading the vi (with Firefox) the name gets mangled...

I attached a cleaned version of your vi, there was a race condition and some overhead...
To use this more often in your program: What about making an XControl?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(3,883 Views)
If the number of elements is small and all are to be displayed, use a cluster for the user interface and convert to array on the diagram for processing. The user has no possibility of adding elements to a cluster. The only coding required is a single cluster to array primitive.

Lynn
Message 9 of 12
(3,878 Views)
Did you attach the cleaned version?
0 Kudos
Message 10 of 12
(3,857 Views)