06-27-2016 07:50 PM - edited 06-27-2016 07:50 PM
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://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!!
Solved! Go to Solution.
06-27-2016 09:50 PM
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?
06-28-2016 02:09 AM
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.
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
06-28-2016 11:56 AM
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?
06-28-2016 11:59 AM
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.
06-28-2016 05:09 PM
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
06-28-2016 07:43 PM
@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.
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.
07-05-2016 09:59 PM
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.