LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increase array size inside while loop

Solved!
Go to solution

testsnippet.pngMy goal is to change the array size of elements from 25 to 50 each time I select a different. I am probably going the wrong way with this because I tried using a local variable and it keeps increasing until it crashes.

which better way I can do this.

If I block value is 0, array should display in front panel 25 boolean, if 1, it should display 50 Booleans (that's the tricky part). I cant seem to reinitialize the array after it increases by 25.. it keeps increasing.. Please help...

Download All
0 Kudos
Message 1 of 8
(4,917 Views)

"each time I select a different ....."     a different what?

 

You aren't doing anything with your shift register, so you really aren't increasing any size of array.

 

If you were, then it would grow quickly and blow up LabVIEW because you have an infinite while loop that is running as fast as it can.

 

What do all of these booleans represent?   What are you trying to do with them when you aren't changing the control from 0 to 1 or back to 0?

0 Kudos
Message 2 of 8
(4,910 Views)

The Booleans represent an array of channels. for block (G,H,I) there are 25 channels. for I there are 50 channels. I want to give a user the choice to select which channel to turn on by displaying all available channels when a specific block is selected.

I think I was coding it wrong and I may need help going in the right direction

0 Kudos
Message 3 of 8
(4,906 Views)

Hi ritch,

 

I may need help going in the right direction

Well, I recommend to use an event structure!

You need:

- value change event for your "block" control. For block=0 you limit your array to 25 channels (using ArraySubset). For block=1 you limit the array to 50 elements by appending 25 channels/bits, followed by ArraySubset with length=50 (for safety :D)

- value change event for "Array" to update any hardware outputs…

I also recommend to hide the index display of the array and disable any right-click menus for the array control so the user cannot add/delete any channels by mistake.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(4,883 Views)

I'm still confused on what your code should be doing. Can you list out the steps that your code should be performing.(ie. 1. Wait for user input. 2. Pass user input to main program loop. 3. ...)

 

PS. Would you maybe consider using a tab control? http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/creating_tab_controls/

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

1-Load default array of 25 Booleans

2- if user select block (J), add 25 more elements to the default array starting from the last index.

3- show all 50 Booleans elements in front panel

4- if user select block (G-H-I),do nothing use default array

5-show all 25 Booleans elements in front panel

0 Kudos
Message 6 of 8
(4,875 Views)

Thanks..this code will be used in a bigger code that already have a event structure that execute only by another butter. I don't want my loop to execute when block value changes.

0 Kudos
Message 7 of 8
(4,868 Views)
Solution
Accepted by topic author ritch_by_nature

Hi ritch,

 

I made a quick example (LV2016)…

 

Edit after reading your new messages:

I don't want my loop to execute when block value changes.

Well, your code should react on user input but without executing your code? That's a tough requirement!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(4,866 Views)