08-18-2022 11:41 AM
Hello,
I want to add a row of data each time someone presses the "Log" button. The array of data will be a max column length of 5. Each row of data is a little tricky: the boolean Channel# control indicates which channel is being checked and only the index that is active has a value. For example, if channel is TTFFF and the Value array is 12345, then the row that gets added to the array would be 12000. I had trouble inserting into the array if it was empty so my first step is to make a row of zeros, then add the data. My vi works, I just think there's probably a better way.
Example functionality:
Channel #= TFTFT
Value =11111
Log is Pressed->
Array = 10101
Channel #= TTTTF
Value = 22222
Log is Pressed->
Array = 10101
22220
Solved! Go to Solution.
08-18-2022 11:59 AM
Use Build Array to add in your elements instead of Insert Into Array.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
08-18-2022 12:42 PM - edited 08-18-2022 12:46 PM
If you don't like your VI, attach it so we can show how to improve it!
Many things are way too ambiguous:
@simmertime wrote:
I want to add a row of data each time someone presses the "Log" button. The array of data will be a max column length of 5.
What should happen if you press the log button 6 times? (ignore the pressing? add row and discard the oldest? something else?)
@simmertime wrote:
Example functionality:
Channel #= TFTFT
Value =11111
Log is Pressed->
Array = 10101
Channel #= TTTTF
Value = 22222
Log is Pressed->
Array = 10101
22220
You need to explain the algorithm.
08-18-2022 01:07 PM
I added the vi to the post but it isn't there anymore. My apologies.
08-18-2022 02:00 PM - edited 08-18-2022 02:03 PM
Hi simmertime,
why do you think you need to insert into an array when you want to build an array? Why not rely on BuildArray function in such cases???
Your VI can be simplified to this:
We don't know what's done in this missing subVI…
Is there a reason you start with a 2×5 array of zeros?
08-18-2022 02:02 PM
08-18-2022 02:06 PM
This is exactly what I was looking for. I tried to use my subvi which takes the boolean channel number and makes an array of only the active channels, but it makes way more sense not to use it. Thank you!