LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an easy method for appending text to a string control / indicator and keeping the colours

Solved!
Go to solution

Hello,

 

Bassically I want to append text to a string control / indicator without losing the formatting of the previous text.


For part of a program that I am creating, data will be transmitted to and received from a serial device. I would like to display this data in a string control / indicator and change the text colour of certain strings  depending on the data type (transmitted, received). Basically like a nice log window.

 

What I am trying to do 

 

At the moment, I am updating the string control / indicator by reading the text and concatenating it with the new string. However, using this method removes the previous text colours 😞


Is there a way to append data to the string control / indicator without losing the previous text formatting?

 

I've started creating a sub vi that reads the text one character at a time and adds a new element to an array (offset and text colour) if the colour is different from the previous character. Only problem is that it seems to be quite CPU intensive.

 

Thanks in advance,

 

Matt

0 Kudos
Message 1 of 3
(3,986 Views)
Solution
Accepted by topic author mattb-5906

mattb-5906 wrote:


Is there a way to append data to the string control / indicator without losing the previous text formatting?


Basically, no. This means you have to use workarounds. Your workaround seems a bit involved. Basically, all you need to do is just keep track of the selection start/selection end pairs that need to be colored in an array. Then you just need to loop through this array to color the text marked by the start/stop positions. 

 

An alternative is to use a different indicator. Rather than a string indicator you could use a table with one column. You can then set the foreground color on a cell-by-cell basis, and adding a new line (row) will not affect the coloring of previous rows.

Message 2 of 3
(3,970 Views)

smercurio_fc wrote:

Basically, no.


...Damn lol

 


smercurio_fc wrote:

Basically, all you need to do is just keep track of the selection start/selection end pairs that need to be colored in an array. Then you just need to loop through this array to color the text marked by the start/stop positions. 

 

An alternative is to use a different indicator. Rather than a string indicator you could use a table with one column. You can then set the foreground color on a cell-by-cell basis, and adding a new line (row) will not affect the coloring of previous rows.


Good point. I'm just not thinking right today. I shall give it a go.

 

Thanks very much 🙂

 

Matt

 

Message Edited by mattb-5906 on 03-23-2009 10:58 PM
0 Kudos
Message 3 of 3
(3,959 Views)