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: 

Simple array of Strings

Hi, I am new to LabView, however I have programmed in various languages to a moderate level.

 

I have attached the vi that I am working on to test a simple array.

 

All I want it to do for just now so I can get my head around LabView arrays is simply add the string to the array each time the button is pressed.

 

So each time the button is pressed I want to add an new element to the array. So after say 10 presses there should be 10 elements

 

Regards,

 

jmcall10

0 Kudos
Message 1 of 4
(2,081 Views)

Use a simple shift register.

If the button is pressed, add this element to the array, else pass the same array to the next loop iteration using the shift register. See the modified code.

Prashanth N
National Instruments
Message 2 of 4
(2,064 Views)

Some general suggestions:

 

  1. Use latch action boolean (right-click..mechanincal action). This way it is true until read by the code, the reverts autoamtically back to false (no need for the local variable).
  2. Your sequence structure has no purpose. Adding to the array is basically instantaneous, so you can add the delay outside. The execution order does not matter.
  3. Pachi: Your Current VI has no wait unless you press the button, meaning it spins like crazy, consuming all CPU while doing nothing. The wait should be outside the case.
  4. Pachi: You need to initalize the shift register, else it remembers the data from previous runs.
  5. Pachi: It is much less efficient to add to the beginning of the array. I recommend to add the new element to the end.

 

Here's a quick draft...

 

 

 

(personally, I would use an event structure, but this should get you started).

 

 

0 Kudos
Message 3 of 4
(2,041 Views)

Hi Altenbach,

Thank you for those suggestions. I knew 3 and 4, but 5 wasn't something I had thought of.

Thank you!

Prashanth N
National Instruments
0 Kudos
Message 4 of 4
(2,025 Views)