Showing results for 
Search instead for 
Did you mean: 

VBS with Diadem

VBS with Diadem



Im using VBS when report something on Diadem&Labview.


I want to geth Local APPdata path where my TDMS file in. Then I open this TDMS file and read it. But somethings going wrong. 


Set path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Set TdmsHdr = DataFileHeaderAccess(path & "dataReport.tdms", "TDMS", ReadOnly)


Is this code wrong ?

Yasemin Barutçu
Electrical And Electronics Engineer
0 Kudos
Message 1 of 4

Re: VBS with Diadem

Hi Yasemin,


What do you mean "something's going wrong?"  How is something going wrong?  Are you getting an error, or is the code simply not executing like you expect it to?


It will be hard to tell you what is going wrong unless we know what, specifically, you're experiencing.  Additionally, the problem may be in other lines besides these two, so it may help to post your entire code so that we understand the context of the problem.


If you're simply trying to load a TDMS file, try using DataFileLoad:


Call DataFileLoad(Path & "dataReport.tdms")


Also, in case it helps, DIAdem has a list of commonly needed paths stored in environment variables.  You can see some of these variables here:

Derrick S.
Product Manager
National Instruments
Message 2 of 4

Re: VBS with Diadem

Yes, I was getting error. I thought the function which gets local appdata path is wrong.

Yasemin Barutçu
Electrical And Electronics Engineer
0 Kudos
Message 3 of 4

Re: VBS with Diadem

I am not sure your Environment object is refering to and if your readonly is a bool variable.

The example includes the two ways to access the file without loading it and the command

to import it. In new applications I would prefere to use the DataStoreto access the meta information.





Option Explicit  'Forces the explicit declaration of all the variables in a script.

dim readonly : readonly = TRUE
dim path : path = "C:\temp\example.tdms"

Function FileOpenXmlParameter(filePath, readonly)

  FileOpenXmlParameter = "<filename"
  if(readonly) then
    FileOpenXmlParameter = FileOpenXmlParameter + " readonly=""yes"""
  end if
  FileOpenXmlParameter = FileOpenXmlParameter + ">"
  FileOpenXmlParameter = FileOpenXmlParameter + replace(replace(filePath, "&", "&amp;"), "<", "&lt;")
  FileOpenXmlParameter = FileOpenXmlParameter + "</filename>"
End Function

'' Access meta information (properties of files) only. File is not loaded into DIAdem

' Use DataFileHeaderAccess
dim TdmsHdr : Set TdmsHdr = DataFileHeaderAccess(path, "TDMS", TRUE)
MsgBox TdmsHdr.ChnNameGet(1,2)

' Use DataStore API
dim store : set store = Navigator.ConnectDataStoreByParameter("TDMS", FileOpenXmlParameter(path, readonly))
MsgBox store.RootElements.Item(1).Children.Item(1).Children.Item(2).Name


'' Load file into DIAdem

DataDelAll 1
DataFileImport path, "TDMS"
MsgBox data.Root.ChannelGroups.Item(1).Channels.Item(2).Name
'' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''



0 Kudos
Message 4 of 4