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: 

write multiple strings in a single string indicator

I have a text ring in which a select an item. What I want is to be able to run the application a single time with the run button, and add multiple items, so that they appear one after the other in a list downwards.

I will leave as an attachment what I have so far.

Any examples, and code will be greatly appreciated.

Thanks.

0 Kudos
Message 1 of 11
(6,691 Views)

Two things:

Shift Register

Concatenate String

 

EDIT:

I see you have these in your code, but your architecture is overall, messed up.  You need a while loop.  The 1 iteration For Loop is pointless.  The case structure needs to be inside the while loop.

 

Do you want to build a string or an array?  Pick one or the other and stop dancing between both.

 

If you do use an array, don't use Insert into Array.  It is the wrong function 99% of the time.  The correct function when putting data at the beginning or end of an array is Build Array.

0 Kudos
Message 2 of 11
(6,672 Views)

The reason why "Insert into array" is wrong is that it resizes the array in memory. This means that LabVIEW needs to spend extra time reordering things in memory so that the array has room to grow.  It has to do this every single loop iteration.  Build array doesn't do heavy shifting around like this, and so it will operate far, far faster.

 

I am also confused as to why you have a foor loop with 1 iteration and a shift register.  A couple extra comments/questions...

 

Why are you initializing to 0 and manually adding 1 in a shift register?  That is what your loop iteration count already does (the blue I in your lower left corner)

Why are you bothering with an array at all?  Every line just concatenate 3 items:  Current text + cr/lf + new text.

 

0 Kudos
Message 3 of 11
(6,656 Views)

I already fixed it.

0 Kudos
Message 4 of 11
(6,654 Views)

@Nando88 wrote:

I already fixed it.


 

I would hardly call that "Fixed"...

 

Some more comments:

 

  1. Never hide wires behind structures. Makes the code hard to read
  2. Never hide controls behind structures. Makes the code hard to read
  3. Never wire false constants in to loops.
  4. You still have you shift register acting exactly like your loop index.
  5. Your lower shift register (integer) will NEVER = 1.  You initialize it to 0, and it just gets passed forever around in that shift register never changing.
  6. You take a string. Turn it into a 1d array, then turn that array into a string. Your string out = your string in... completely useless.
  7. Earlier you take the same string, build a 1d array, put it to the edge of your case structure, and then it sits there going nowhere else.
  8. Way overuse of local variables. While not technichally wrong, local variables make your code harder to read. Think dataflow.
  9. You have a random constant of "1" just floating out there.
  10. You should be using an event structure instead of your loop spinning as fast as it can looking for your bools to be true
  11. Your "stop" button is not wired in to anything, and the button that actually stops the inner loop is hidden.
0 Kudos
Message 5 of 11
(6,642 Views)

Here is a modified VI that does what you are trying to do, with all the unnecessary code deleted.

0 Kudos
Message 6 of 11
(6,613 Views)

@BowenM wrote:
I would hardly call that "Fixed"...
(Long list of comments)

In addition:

  • Not sure if yout string shift regsiter should be initialized.
  • You have way too much duplicate code. For example the Ring2 Strings[] property node exists in every single one of the cases of the case structure. It belongs after the case structure, only one instance needed. The Case structure should only contain things that differ!
  • Don't use switches for latch action. It confuses. Use buttons.
  • ...

 

 In any case, here's a quick rewrite of your VI showing some possible simplifications. See if it makes sense.

As has been mentioned, you should use event structures, so modify as needed.

0 Kudos
Message 7 of 11
(6,608 Views)

Thanks for the code.

I made some changes to it, now I'm trying to print the results in a table.

The problem I'm having is that the second text ring will not update, and the second time I try to change the first text ring, the app crashes and stops responding.

Can some one please help me?

I'll leave the code I'm using.

Thanks!

0 Kudos
Message 8 of 11
(6,559 Views)

Two event structures in the same while loop.  BAD idea.

 

On top of that, all your event cases in both structures are set to Lock the Front Panel until the event completes.  So if your code is waiting for an event in event structure #1, and you fire an event that is registered in event structure #2, your front panel will lock up.  You'll never be able to trigger an event registered in #1 to get the code to continue executing.

 

Try using timeouts.  Try setting all the event cases to not lock the front panel.  It may start behaving.  But I still wouldn't recommend it.  The architecture is still set up wrong.

 

Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2013 Help

0 Kudos
Message 9 of 11
(6,540 Views)

I removed the event structure for the text ring, but the second text ring still will not update.

Can someone please help me?

Thanks.

0 Kudos
Message 10 of 11
(6,505 Views)