From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a 2d Table programatically

Hi,

Can anyone plese tell me how to create a 2D table in the report device programatically.

Thanks,
0 Kudos
Message 1 of 18
(5,225 Views)
First you have to create a table, then you can set the position and the data. To get the parameter for setting the data and position open the corresponding dialog and press . DIAdem stores the parameters in the clipboard or recorded them if you are in the recording mode of DIAdem script.
You access the table by its name.

Call GraphObjNew("2D-Table","MyTable")
Call GRAPHObjOpen("MyTable")

'Set position
D2TABTOP =10
D2TABBOTTOM =50
D2TABLEFT =50
D2TABRIGHT =10

'Set data
D2TABAUTOSCALTYP ="fixed"
D2TABBEGIN =1
D2TABEND =10
D2TABNODIST =1
D2TABDATATYPE(1) ="Channel"
D2TABCHNNAME(1) ="[1]/Time"
D2TABRELWIDTH(1) =1
D2TABOPTIONALLEN(1)=""
D2TABDATATYPE(2) ="Channel"
D2TABCHNNAME(2) ="[1]/Speed"
D2TABRELWIDTH(2) =1
Call GRAPHObjClose("MyTable")

'Refresh REPORT
Call PicUpdate


Hope this helps
Winfried
0 Kudos
Message 2 of 18
(5,221 Views)

Hello,

 

this is quite an interesting thread for a beginner like me, though it is eight years old now.

I would like to display some properties of a given channel (but not all of them) in a 2D table, like

 

Number

Name

Property4

Property7

Property8

 

Would you know how to do this with DIAdem 2011 (via script of course) ? There are very few code examples on the Internet showing how to display some table the way you wish.

Thanks in advance.

0 Kudos
Message 3 of 18
(4,766 Views)

Ok I have found something that works (in another thread of this forum) :

 

Call GlobalDim("Tblcol1(4), Tblcol2(4)")

Tblcol1(1) = "Root Name"
Tblcol1(2) = "Group Name"
Tblcol1(3) = "Channel Name"
Tblcol1(4) = "Channel Number"
Tblcol2(1) = RootPropValGet("Name") 

 

but then, I could not put titles for columns. So I found another way... but it does not compile. I really wish this code worked because then it is quite easy to add titles. This is the code I am talking about :

 

Call GraphObjNew("2D-Table", "Table1")
Call GraphObjOpen("Table1")
Set oColumns = Table1.Columns

Table1.Columns.Item(1).Cells(2).Value = "Root Name"
Table1.Columns.Item(1).Cells(3).Value = "Group Name"
Table1.Columns.Item(1).Cells(4).Value = "Channel Name"
Table1.Columns.Item(1).Cells(5).Value = "Channel Number"
Table1.Columns.Item(2).Cells(2).Value = RootPropValGet("Name") 

Call GraphObjClose("Table1")

 found here. Could you please help me out ?

0 Kudos
Message 4 of 18
(4,760 Views)

Hi Near,

 

Your latest post suggests you are in fact using DIAdem 2012, the first DIAdem version which supports the Report object.  Please specify clearly whether a solution that works only in DIAdem 2012 is acceptable-- this will be much easier to provide.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 18
(4,752 Views)

Hi Brad,

 

I do not have DIAdem 2012 for sure. But since the link I provided has "DIAdem 2011 Help" written in the title, it then occured to me that those lines should work. Apparently I was wrong.

0 Kudos
Message 6 of 18
(4,745 Views)

Hi Nera3

 

The help topic you find belongs to the SUD Dialog box editor of DIAdem (the disadvantage of the help in the web is that is hard to find the context). In DIAdem 2012 it would be easy as in this example but you use DIAdem 2011 so you have to use the old way :-<

The easiest way is to do it manually in REPORT and the press CTRL-A (In DIAdem 2012 CTRL-Shift-C). Then DIAdem will copy some code in the clipboard that you can paste into SCRIPT. You can also copy the properties from the DataPortal to SCRIPT to find the code to access the properties. Finally you will get some code similar to this (I removed a lot of recorded code):

Call GraphObjOpen("2D-Table")
  '------------------- Table --------------------------
  D2TabDataType(1) = "Channel"
  D2TabVariable(1) = ""
  D2TabChnName(1)  = "[1]/Geschwindigkeit"
  '------------------- Headline --------------------------
  D2TabTxtVector(1)= "Name: @@Data.GetChannel(#).Properties(""name"").Value@@"
  D2TabTxtVector(2)= "Name: @@Data.GetChannel(#).Properties(""number"").Value@@"
  D2TabTxtVector(3)= "Name: @@Data.GetChannel(#).Properties(""MyProperty"").Value@@"
Call GraphObjClose("2D-Table")

 To create the table use the code:

Call GraphObjNew("2D-Table","2D-Table")

 Finally you have to update the REPORT

'Refresh REPORT
Call PicUpdate

 

Hope this helps

 

Winfried

0 Kudos
Message 7 of 18
(4,734 Views)

Hi Winfried,

 

Ok so it worked ! My only problem now is that everything is quite narrow. See below. Would you know a way to fix this ?

 

Also if possible, I would be interested in putting different Titles to each column !

0 Kudos
Message 8 of 18
(4,729 Views)

Hi Near3

 

Have you tried the CTRL-A trick? It will create code for all possible settings and you can remove what you do not need.

 

To create individual you have to use D2TabTxtType

  D2TabTxtType(1)  = "column defined headline"
  D2TabHeaderTxt(1,1)= "Name: @@Data.GetChannel(#).Properties(""name"").Value@@"
  D2TabHeaderTxt(1,2)= "Name: @@Data.GetChannel(#).Properties(""number"").Value@@"

 

The hight could be set with D2TabTxtField. If you mark the word in SCRIPT and press F1 the help will show you the help for this variable.

Hope this helps

 

Winfried

 

0 Kudos
Message 9 of 18
(4,720 Views)

I have tried it more than once but I have never pasted anything sadly... Or maybe I missed something ? For example, I manually added some text (as a title) on top of the second column, then pressed CTRL + A, then tried to paste somewhere, but nothing appeared.

 

Anyway, your code adds the second header just under the first one, still in the first column. At least it does on my computer. So I assumed that by (1,2) you actually meant (2,1) and tried it as well, but the title does not even show up that way. 😞

 

Thanks for your effort.

0 Kudos
Message 10 of 18
(4,714 Views)