05-17-2012 03:07 AM
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 ?
05-17-2012 10:30 AM
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/
05-18-2012 12:05 AM
Yes, I was getting error. I thought the function which gets local appdata path is wrong.
05-18-2012 12:10 PM - edited 05-18-2012 12:11 PM
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, "&", "&"), "<", "<") 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
'' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''