11-17-2014 04:57 AM
I get several error messages when creating more than one channel table and wanting to display the channel descriptions. Is there something wrong with the assignment of the description value to the header line? I attached a minimum example:
Option Explicit 'Forces the explicit declaration of all the variables in a script. Call Data.Root.Clear() Call DataFileLoad("C:\Program Files (x86)\National Instruments\DIAdem 2014\Examples\Data\Example_data.tdm") Call Report.NewLayout() Dim oMySheet, oMyTable, oMyColumn, oMyGrp, iCount, gCount For gCount = 1 To GroupCount Set oMyGrp = Data.Root.ChannelGroups(gCount) Set oMySheet = Report.Sheets.Add("Table" & gCount) Set oMyTable = oMySheet.Objects.Add(eReportObject2DTable,"Table" & gCount) oMyTable.Settings.Header.Title2 = "@@Data.Root.ChannelGroups(CurrGroupIdx).Channels(CurrChnNo).Properties("& Chr(34) &"description"& Chr(34) &").Value@@" oMyTable.Settings.Header.UseAutoFontSize = TRUE oMyTable.Position.ByBorder.Bottom = 5 oMyTable.Position.ByBorder.Top = 5 oMyTable.Position.ByBorder.Left = 5 oMyTable.Position.ByBorder.Right = 5 For iCount = 1 To oMyGrp.Channels.Count Set oMyColumn = oMyTable.Columns.Add(e2DTableColumnChannel) oMyColumn.Channel.Reference = oMyGrp.Channels(iCount).GetReference(eRefTypeIndexName) Next Next Call Report.Refresh()
As you will see, everything works fine for the first table, but errors are produced for all the following ones.
/Phex
Solved! Go to Solution.
11-17-2014 06:16 AM
Hello Phex,
Your script works fine on my PC. I tested it with DIAdem 2014. What is your version?
Greetings
Walter
11-17-2014 06:36 AM - edited 11-17-2014 06:36 AM
It is 14.0.0f5641
The script runs through without interruption, but there are error messages of this kind in the log file:
"The index XX does not match any of the elements in the list."
When opening and closing the properties of a channel table other than the first, a warning message pops up:
"Several errors or warnings have occured.
Check the logfile for details."
11-17-2014 07:44 AM
Hi Phex,
You're right. I didn't check the log file. It seems that there are some initializations are missing. If you start your script with command to open REPORT first it works well.
call WNDShow("Report", "maximize")
Greetings
Walter
11-17-2014 08:10 AM
Where exactly did you put "Call WNDShow("Report", "maximize")" in the script ? I tried it with the command right at the beginning but it didn't make any difference.
/Phex
11-17-2014 08:14 AM
As first command - before the first REPORT command.
Greetings
Walter
11-17-2014 08:21 AM
Sorry, but that doesn't seem to work for me. Same error messages as before.
/Phex
11-17-2014 09:23 AM
We need to analyze this more in detail. I created an entry for the developer's.
Greetings
Walter
11-18-2014 03:20 AM
Hi Phex,
We found the problem. It was a wrong in index in the definition of the column header. Here is the fixed code:
call WNDShow("Report", "maximize") Call Report.NewLayout() Dim oMySheet, oMyTable, oMyColumn, oMyGrp, iCount, gCount For gCount = 1 To GroupCount Set oMyGrp = Data.Root.ChannelGroups(gCount) Set oMySheet = Report.Sheets.Add("Table" & gCount) Set oMyTable = oMySheet.Objects.Add(eReportObject2DTable,"Table" & gCount) ' oMyTable.Settings.Header.Title2 = "@@Data.Root.ChannelGroups(CurrGroupIdx).Channels(CurrChnNo).Properties("& Chr(34) &"description"& Chr(34) &").Value@@" oMyTable.Settings.Header.UseAutoFontSize = TRUE oMyTable.Position.ByBorder.Bottom = 5 oMyTable.Position.ByBorder.Top = 5 oMyTable.Position.ByBorder.Left = 5 oMyTable.Position.ByBorder.Right = 5 For iCount = 1 To oMyGrp.Channels.Count Set oMyColumn = oMyTable.Columns.Add(e2DTableColumnChannel) oMyTable.Settings.Header.Title2 = oMyGrp.Channels(iCount).Properties("description").Value oMyColumn.Channel.Reference = oMyGrp.Channels(iCount).GetReference(eRefTypeIndexName) Next Next Report.Refresh
Greetings
Walter
11-18-2014 04:16 AM
Hi Walter,
thanks for the input. In the meanwhile I found a more versatile solution, which even updates the channel description in the report when it is being changed afterwards by using the ChnComment command:
Call Data.Root.Clear()
Call DataFileLoad("C:\Program Files (x86)\National Instruments\DIAdem 2014\Examples\Data\Example_data.tdm")
call WNDShow("Report", "maximize")
Call Report.NewLayout()
Dim oMySheet, oMyTable, oMyColumn, oMyGrp, iCount, gCount
For gCount = 1 To GroupCount
Set oMyGrp = Data.Root.ChannelGroups(gCount)
Set oMySheet = Report.Sheets.Add("Table" & gCount)
Set oMyTable = oMySheet.Objects.Add(eReportObject2DTable,"Table" & gCount)
oMyTable.Settings.Header.Title2 = "@@ChnComment(CCN)@@"
oMyTable.Settings.Header.UseAutoFontSize = TRUE
oMyTable.Position.ByBorder.Bottom = 5
oMyTable.Position.ByBorder.Top = 5
oMyTable.Position.ByBorder.Left = 5
oMyTable.Position.ByBorder.Right = 5
For iCount = 1 To oMyGrp.Channels.Count
Set oMyColumn = oMyTable.Columns.Add(e2DTableColumnChannel)
oMyColumn.Channel.Reference = oMyGrp.Channels(iCount).GetReference(eRefTypeIndexName)
Next
Next
Call Report.Refresh()
Could you please explain why it was not working with my previous code?
oMyTable.Settings.Header.Title2 = "@@Data.Root.ChannelGroups(CurrGroupIdx).Channels(CurrChnNo).Properties("& Chr(34) &"description"& Chr(34) &").Value@@"
Another example scenario would be if I may want to display the first channel value of each channel:
oMyTable.Settings.Header.Title2 = "@@Data.Root.ChannelGroups(CurrGroupIdx).Channels(CurrChnNo).Values(1)@@"
OR when wanting to show a self-assigned property:
For iCount = 1 To oMyGrp.Channels.Count Set oMyColumn = oMyTable.Columns.Add(e2DTableColumnChannel) oMyColumn.Channel.Reference = oMyGrp.Channels(iCount).GetReference(eRefTypeIndexName) Call oMyGrp.Channels(iCount).Properties.Add("xyz","abc") Next oMyTable.Settings.Header.Title2 = "@@Data.Root.ChannelGroups(CurrGroupIdx).Channels(CurrChnNo).Properties("& Chr(34) &"xyz"& Chr(34) &").Value@@"
These examples produce the same strange behaviour.
The general question would be: How can I display updatable channel properties in REPORT using an object-oriented approach?
/Phex