03-23-2009 04:53 PM
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.
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
Solved! Go to Solution.
03-23-2009 05:41 PM
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.
03-23-2009 05:58 PM - edited 03-23-2009 05:58 PM
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