DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Text parameters in a 2d table

How can I change the text parameters (such as color) in a specific column/row location in a 2D table? Changing the color for an entire column is obvious, but I can't find a method for changing a single table value.

I have tables which are mostly populated with channel property values. I would like to change certain values to red if they fail to meet a spec.

 

0 Kudos
Message 1 of 10
(5,159 Views)

This is the way that I do it (with the help of the NI DiaDEM guy):

 

First, we created a USER Command to find the limit based on the min and max limit in my specific table:

 

Function Limit(CurrValue,Min,Max,Offset)
Dim MinLim,MaxLim
MinLim = ChD(D2TabRow+Offset, D2TabChn(Min))
MaxLim = ChD(D2TabRow+Offset, D2TabChn(Max))
IF CurrValue < MinLim or CurrValue > MaxLim THEN
D2TabNumColor(D2TabCol) = "red"
D2TabNumBold(D2TabCol) = 1
ELSE
D2TabNumColor(D2TabCol) = "black"
D2TabNumBold(D2TabCol) = 0
END IF
Limit = CurrValue
End Function ' Limit(CurrValue,Min,Max)

 

Then call that function in the format of the table column:

 

@@str(limit(CFV,2,4,0),"d.ddd")@@

 

Where CFV is the current value, 2 is the column where my minimum limit is, 4 is the column where my maximum limit is, and 0 is the offset.

 

 

0 Kudos
Message 2 of 10
(5,156 Views)

I'm actually trying to do something a little simpler, but I can't seem to make this work.

 

The values in my table that I'd like to change the color of are strings - either the word PASS or FAIL. They already exist as property values of data channels.

 

I'm using this user command:

 

Function FailRed(PFString)
  If PFString = "FAIL" Then
    D2TabNumColor(D2TabCol) = "red"
  Else
    D2TabNumColor(D2TabCol) = "green"
  End If
  FailRed = PFString
End Function

 

It is registered and the extension status shows as Loaded

 

In my table definition, under Column Properties for that column, I have @@FailRed(CFV)@@ in the Text Parameters Format: box.

 

All the tables entries show up as the original black (not red or green) in that column.

I tried changing the font color to none, but that didn't help either - the characters just become invisible.

How to I prevent the Font Color setting from over-riding the user defined formatting value?

Or, perhaps I'm doing something else wrong.

 

Thanks

 

0 Kudos
Message 3 of 10
(5,132 Views)

It may be that you are not formatting the data properly.  CFV is a real number, and you are comparing it to a string.  Try changing it to 1s and 0s and see if that changes the functionality.

0 Kudos
Message 4 of 10
(5,128 Views)

I tried putting 1's and 0's in the table, and changing the function to test for them - with the same result.

No color change is occuring.

 

 

0 Kudos
Message 5 of 10
(5,126 Views)

Nothing I put in the Format: box seems to affect any numbers in the table columns. This includes the common built-in formats such as d.dd,  #hh:nn, etc.

 

I am using the Text list Data Type in the table. The example I found in the help files uses the Channel Data Type. Perhaps that is the issue.

 

If I select either Expression or Variable as the Data Type in the Table Columns tab, the "Format:" box is ghosted out in the Column Properties/Text Parameters tab. However, they are not ghosted for Channel and Text list Data Types. There does seem to be some odd behavior when selecting the Text List Data Type after selecting Expression or Variable Data Types. The "Format:" box remains ghosted until the Channel Data Type is selected first. Then "Text List" can be selected and the "Format:" box is not ghosted.

 

The data in my table does not come from within a channel - it comes from property values previously written that that channel.I have been using the Text List Data Type and then using an variable such as

@@Data.GetChannel("[1]/Channel Data").Properties("A_Property_Value").Value@@

in the column textlist.

 

Attached is a simple table with text entered into the Column Text lists which show how common formatting values can be entered, but are ignored in the data within the table.

 

 

 

 

 

0 Kudos
Message 6 of 10
(5,109 Views)

I'm beginning to wonder if what I need to do can be done.

 

There seems to be no way to change the color of a table entry at a specific column/row location. All the variables that I can write to deal with entire columns only - such as D2TabNumColor(i).

 

There is a read-only variable D2TabRow (which does me no good), and a writeable variable D2TabTextRow, but I don't understand how to make use of it.

 

I tried specifying a row with it before using D2TabNumColor(i), but it still changes the color of every entry in column (i).

 

Is there a way to independently change colors of data in specific table locations? If so, could someone provide some very simple example code?

0 Kudos
Message 7 of 10
(5,096 Views)

Hi Greg,

 

It is possible to color the font of the cell text conditionally with a User Command and a custom draw event.  I'm attaching an example of this.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 10
(4,979 Views)

Hi Brad,

 

That example uses data from a data channel. That does me no good. My data comes from property values previously written to that channel. These property values are the words "PASS" or "FAIL".


Please see my message above with the attachment called TableExample.zip.  It's just a very simple .tdr file, but I believe it illustrates my problem at a basic level. 

 

In it I apply a time format to a string that represents a time of day. I would expect it to show AM or PM.  I also tried to apply a d.dd format to numbers with different numbers of decimal points. Nothing is changed in the way the numbers are displayed.

 

I think my problem with being unable to change font colors is exactly the same problem that causes this example to fail.

 

 

 

0 Kudos
Message 9 of 10
(4,958 Views)

Hi Greg,

 

The example I sent shows you how to conditionally color the font based on the displayed value in each cell.  That's the hard part of what you're asking for.  Here is an example that displays Group properties based on the Group index and the table cell's row and column.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 10
(4,939 Views)