DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Report: channel description error in multiple tables

Solved!
Go to solution

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

0 Kudos
Message 1 of 12
(5,545 Views)

Hello Phex,

 

Your script works fine on my PC. I tested it with DIAdem 2014. What is your version?

 

Greetings

Walter

0 Kudos
Message 2 of 12
(5,539 Views)

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."

0 Kudos
Message 3 of 12
(5,535 Views)

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

0 Kudos
Message 4 of 12
(5,527 Views)

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

0 Kudos
Message 5 of 12
(5,524 Views)

As first command - before the first REPORT command.

 

Greetings

Walter

0 Kudos
Message 6 of 12
(5,522 Views)

Sorry, but that doesn't seem to work for me. Same error messages as before.

/Phex

0 Kudos
Message 7 of 12
(5,520 Views)

We need to analyze this more in detail. I created an entry for the developer's.

 

Greetings

Walter

0 Kudos
Message 8 of 12
(5,507 Views)

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

0 Kudos
Message 9 of 12
(5,491 Views)

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

0 Kudos
Message 10 of 12
(5,486 Views)