03-15-2013 10:09 AM - edited 03-15-2013 10:12 AM
Hi,
Really new to programming and Diadem in general. I am trying to figure out how to automatically display mean and standard deviation from multiple channels in multiple groups. I have set up code to create the property data, I just do not know how to display them in a table format. Is there a reference for linking code to table name and values? For instance I have this so far:
For
d = 1toData.Root.ChannelGroups.Count
CallGraphObjOpen("2DTable1")
D2TabChnName(d) = Data.Root.ChannelGroups(d).Channels("Front Left Long").Properties("ResultStatArithMean").Value
...
I know that this makes the name of the table what ever value the arithmean is, but how do I have the ArithMean a value within the table?
Thanks,
David
03-15-2013 10:29 AM
Also, what is this dialog box <Ctrl A> that I see mentioned. Where can I find it/activate it?
Thanks
03-18-2013 12:46 PM
Datasker,
The key to doing this is to set the table column type to Expression, rather than Channel. This allows you to write a DIAdem expression for the channel information. I made two expression columns, with the following expressions:
Column 1 Expression: @@ChnPropGet(D2TabRow,"name")@@
Column 2 Expression: @@ChnPropGet(D2TabRow,"ResultStatArithMean")@@
This gives me a table with the name of each channel and the custom property value corresponding to it. To actually get this into a script, I used the script recording function, which brings up your second question about the Ctrl+A command. When recording a script, if you press Ctrl+A (or Ctrl+Shift+C in DIAdem 2012) on a dialog box, the values in the dialog will be inserted into the script. Try these steps:
1. Go to SCRIPT window, and click the "Enable Recording Mode" button. Set the values for author and etc appropriately, then click OK.
2. Go to REPORT window, right-click on your table and choose Display, and configure the columns as described above. Before closing this Display screen, hit Ctrl+A.
3. Go back to the SCRIPT window and click to end recording mode. You'll see that the script now has tons of code in it, mostly because the Display window has a lot of options and all of these are recorded into the script. If you were to run this script, you would see that it does exactly what you did when you configured the settings manually.
Most of those parameters from the Display window are unnecessary, so you can just delete them. I did this, and made a few other changes (I made my script delete the existing table data before it adds the new data, and mine also automatically refreshes the report when it's done. Here's that simplified script:
Option Explicit 'Forces the explicit declaration of all the variables in a script. 'Declare variables Dim oCtrl, o2DTable, o2DTableColumns, o2DTableColumnExpression Set oCtrl = Report.Sheets("Sheet 1").Objects("2D-Table") Set o2DTable = oCtrl o2DTable.Name = "2D-Table" Set o2DTableColumns = o2DTable.Columns 'remove any existing columns Call o2DTableColumns.RemoveAll 'add two new columns Call o2DTableColumns.Add(e2DTableColumnExpression) Call o2DTableColumns.Add(e2DTableColumnExpression) 'set the first column Set o2DTableColumnExpression = o2DTableColumns.Item(1) o2DTableColumnExpression.Expression = "@@ChnPropGet(D2TabRow,""name"")@@" 'set the second column Set o2DTableColumnExpression = o2DTableColumns.Item(2) o2DTableColumnExpression.Expression = "@@ChnPropGet(D2TabRow,""minimum"")@@" 'Refresh report window Call PicUpdate()