From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add row to array each time the "Log" button is pressed

Solved!
Go to solution

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

0 Kudos
Message 1 of 7
(878 Views)

Use Build Array to add in your elements instead of Insert Into Array.

Redhawk
Test Engineer at Moog Inc.

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.

0 Kudos
Message 2 of 7
(866 Views)

If you don't like your VI, attach it so we can show how to improve it!

 

Many things are way too ambiguous:

 

  • What's the mechanical action of the log button?
  • Where is the array kept (shift register? swarms of local variables? etc.)
  • Do you use event structure or polling?
  • etc.

 


@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.

 

  • TFTFT is NOT a number. What is it? (String of T&F characters? boolean 1D array? integer with a certain bit pattern? something else?
  • You seem to mask the "value" with the channel. What's the datatype? Are all digits of "value" the same for each entry?
  • What is the output "Array"? Integer 2D array? Array of strings?
0 Kudos
Message 3 of 7
(840 Views)

I added the vi to the post but it isn't there anymore. My apologies.

0 Kudos
Message 4 of 7
(822 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(800 Views)
Solution
Accepted by topic author simmertime

See if this can give you some ideas.

 

altenbach_0-1660849297602.png

 

0 Kudos
Message 6 of 7
(798 Views)

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!

0 Kudos
Message 7 of 7
(788 Views)