LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing colour of specific sets for words in text indicator

Solved!
Go to solution

Hi all,

 

I am trying write my first semi-extensive program. It have successfully setup drivers and serial communication for my test steps, which are going well. However, I am having trouble with creating a nice log window. I am currently using a standard text indicator and formatting the PASS/FAIL messages to output to the indicator. 

 

Basically, my subVI tries to determine if the string is PASS or FAIL, and assigns a colour based on that. the index and index+4 (because pass/fail are 4 letter words) are indicators, which inside the MAIN program is looped to increment and find the next instance of PASS or FAIL. 

 

I have taken elements of the following resources:

http://forums.ni.com/t5/LabVIEW/Is-there-an-easy-method-for-appending-text-to-a-string-control/m-p/8...

http://digital.ni.com/public.nsf/allkb/6BD344ACA4DEE20A8625692700737E16

 

However, it seems that only a few words (that aren't even PASS or FAIL) are randomly being assigned red or green. On second pass, the entire log is red for some reason. 

 

I have also tried this in the same loop as the Log Window indicator, and in this case, the correct word changes colour, but everytime a new line is written, everything loses its colour and is all black again. I have can't seem to find a thread with somebody using this exact application. Any help at all would be truly appreciated. Thanks in advanced!!

0 Kudos
Message 1 of 8
(4,433 Views)

Why don't you just compare the incoming string with Pass/Fail strings? Typically how your Incoming string would be? Does it contain other text apart from the PASS/FAIL?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 8
(4,423 Views)

In my opinion, trying to manage a string on a word basis is a bit cumbersome.

 

You could use a Listbox and just set the row to a color. The color can be set when you make an entry. See attached png file.

 

History Log.png

 

A formatted string with a contant-width font will keep items lined up.

In the attached png (it's not a snippet), the "Set History Color" vi is simply a case statement that selects font colors based on

Log Type.

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
Message 3 of 8
(4,401 Views)

Hi P@Anand, thanks for replying. I think I understand what you're saying. However, there is other information I am outputting. I have attached a screenshot for your reference. 

 

I'm wondering if this has something to do with the function I'm using to search: Search/Split String. I am using it with a shift register to update the index. I guess my question is, does it search in order? For example, if my offset index input is (0), will it search from the beginning and return the offset of the FIRST found attempt? 

0 Kudos
Message 4 of 8
(4,369 Views)

Thank you for replying Steve. I am trying the listbox. I am able to change listItems as you have shown, to have colours. I think your suggestion of making the entire line one colour is acceptable for my purposes. Is it possible to implement this in the textbox? I have built a lot around using hte textbox, and I would have to modify quite a few subVIs (or at least add a few loops) to implement the textbox properly. 

0 Kudos
Message 5 of 8
(4,368 Views)

My opinion is that there will be less work in the long run if you use the Listbox approach.

My approach was to implement this as an Action Engine (search if this term is new to you).

 

steve

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 8
(4,335 Views)
Solution
Accepted by topic author getrich

@getrich wrote:

Thank you for replying Steve. I am trying the listbox. I am able to change listItems as you have shown, to have colours. I think your suggestion of making the entire line one colour is acceptable for my purposes. Is it possible to implement this in the textbox? I have built a lot around using hte textbox, and I would have to modify quite a few subVIs (or at least add a few loops) to implement the textbox properly. 


If you want to use a textbox you'll probably need to use the approach from the link in your orignal post.

 

 

Spoiler

Essentially, create a reference for the string indicator, use the Text>Selection->Start and Text->Selection->End in combination with Text->Font->Color.

You'll then need to keep track of where every string you want to change will appear, and re-run the colourisation every time the box is updated, and you'll probably want to recolour the rest of the text black or what ever too to ensure that you don't experience the issue you saw where the entire textbox became the last used colour.

 

Message 7 of 8
(4,322 Views)

Thank you all!

 

I appreciate your idea, Steve, but in the end I made a loop to go through with the method Hornless.Rhino stated. It ended up working out. 

0 Kudos
Message 8 of 8
(4,245 Views)