LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to update a long string indicator

Consider a large string indicator like this:

Clipboard02.jpg

 

I would like to append a string quite often (the appended string is read by the serial port), at the same time maintain the last line visualized.

My code is this for the update (executed often, every time I get a new char at the port):

Clipboard01.jpg 

and then this:

ScrollPos.jpg

 

 

Unfortunately this solution  has a flickering UI problem, because the whole transmission lasts like 80 seconds, so I think that for every char I get the entire (old) string is copied into another string variable that has only one char more...

 

Isn't it possible to append just one char? like the StringBuilder object in .NET, to avoid memory waste (under the hood variables are copied) ?

How to avoid the flickering of the indicator?Is DeferPanelUpdates property enough?

Any good practice?

 

Thanks 

0 Kudos
Message 1 of 5
(3,700 Views)

You are wasting a lot of resources here. Please try this:

 

ProperStringGrowth.png

 

Please note that i used a For-Loop due to show the suggested way: Limit the growth of the string. Otherwise, your system will run out of resources (memory) in a short (or perharps longer) time......

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 5
(3,681 Views)

Slyfer wrote: 

 

 

Isn't it possible to append just one char?


Of course:

 

 

But I'm guessing that's not what you're really asking. Smiley Wink

 


like the StringBuilder object in .NET, to avoid memory waste (under the hood variables are copied) ?

You have a misconception on how StringBuilder actually works. The StringBuilder class will allocate a new buffer if the text appended (whether it's one character or 100 characters) exceeds the current buffer for the instance of the StringBuilder class that you have. 

 

You should be aware that continuously building a string can quickly become a resource hog as more and more memory is allocated. A better approach is to have a pre-allocated set of lines and you basically use the buffer like a FIFO or LIFO (depending on the behavior that you want). 

 


How to avoid the flickering of the indicator?Is DeferPanelUpdates property enough?

Any good practice?


The flickering is not occuring due to the appending of the strings. The flickering is occurring due to updating the scroll position all the time. My suggestion is to make the scroll movement a little smarter. I.e., don't move it all the time, but only when you need to. 

 

 

Message Edited by smercurio_fc on 06-07-2010 10:20 AM
0 Kudos
Message 3 of 5
(3,677 Views)
Whoa thanks for the speedy replies!

I cannot use a for-loop I think, because the updates of the string indicator happens in different locations of the program, in different frames.

I will try to use ScrollDown less frequently.
I got what you mean about StringBuilder buffer. But in that case it is possible to create the object with big buffer (I think it is also handled automatically the case of buffer full). In labview I can only assign variable?! (if one doesn't use the shift register loop)

The string buffer indicator that I use is the serial output of a embedded-Linux device, you know like the router that has a serial port that simply puts out what is going on. This serial line puts out info like the boot (uboot), the modules it is loading, etc...
It's quite a long string, but not huge. The order of kilobyte... 
0 Kudos
Message 4 of 5
(3,655 Views)

Slyfer wrote:
 
I got what you mean about StringBuilder buffer. But in that case it is possible to create the object with big buffer (I think it is also handled automatically the case of buffer full). In labview I can only assign variable?! (if one doesn't use the shift register loop)

Yes.

Message 5 of 5
(3,653 Views)