NI Home > Community > NI Discussion Forums

DIAdem

Showing results for 
Search instead for 
Do you mean 
Reply
Member
No_RegreTs
Posts: 181
0 Kudos

VBS with Diadem

Hello,

 

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
Active Participant
DRock
Posts: 244

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:

 

http://zone.ni.com/reference/en-XX/help/370859J-01/cmdvarlist/cmdvarlist/cmdlist_path/

Derrick S.
Product Manager
NI DIAdem
National Instruments
Member
No_RegreTs
Posts: 181
0 Kudos

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
Active Participant
AndreasK
Posts: 254
0 Kudos

Re: VBS with Diadem

[ Edited ]

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.

 

Greetings

Andreas

 

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
'' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''