DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Properties Copy to DataFileHeaderAccess

Solved!
Go to solution

Hi everyone!

 

I'm trying to Update a old Script from Diadem 9.1 and I'm getting some troubles. The Script use to Copy the Root Properties of some .tdms files were the conditions of the test are stored. For that it used the command .RootPropCount, that now is obsolete.

 

I tried the following Script to get this Count but I do not get the count of the Custom Properties:

 

Set TdmHdr = CreateDataFileHeaderAccess()
Set oMyDataStore = TdmHdr.Open(DataReadPath & "EXAMPLE.TDMS" , "TDMS", True)
PropCount = oMyDataStore.RootElements(1).Properties.Count
MsgBox (PropCount)
 
The result is always 8, regardless of the nº of Costum Properties, and the Name of the DataStore Properties are: name, description, title, autor, datetime, registertxt1, registertxt2 and registertxt3.
 
The .tdms file has indeed more than 30 Costum Properties that are not being obteined...
 
Please help!
 
Thank you in advance.
0 Kudos
Message 1 of 3
(1,760 Views)
Solution
Accepted by topic author Viruje

This is a little pitty because the RootPropCount was doing a second thing internally which was calling 

rootProperties.ListInstanceProperties = True

This little line causes the API to also reflect the custom properties (instance properties).

You need to set it to true for every properties object.

 

 

So the following code will do the job.

 

Option Explicit

dim TdmHdr, oMyDataStore, PropCount

Set TdmHdr = CreateDataFileHeaderAccess()
Set oMyDataStore = TdmHdr.Open(DataReadPath & "EXAMPLE.TDMS" , "TDMS", True)

dim rootProperties : set rootProperties = oMyDataStore.RootElements(1).Properties
rootProperties.ListInstanceProperties = True
PropCount = rootProperties.Count

MsgBox (PropCount)

 maybe you can just add a function to your code to simplyfy the job

Option Explicit

dim TdmHdr, oMyDataStore, PropCount

Set TdmHdr = CreateDataFileHeaderAccess()
Set oMyDataStore = TdmHdr.Open(DataReadPath & "EXAMPLE.TDMS" , "TDMS", True)

dim rootProperties : set rootProperties = GetElementProperties(oMyDataStore.RootElements(1))
PropCount = rootProperties.Count

MsgBox (PropCount)


function GetElementProperties(byref element)
  set GetElementProperties = element.properties
  GetElementProperties.ListInstanceProperties = True
end function
Message 2 of 3
(1,718 Views)

Thank you very much!! Now it works fine.

 

 

0 Kudos
Message 3 of 3
(1,709 Views)