04-16-2015 12:08 PM
I am building an interface in which I would like the user to select the specific test which links to that tests folder. Once test folder is selected, I would like to load all tdms files in that folder. Is there a way to do this? The load data options in Diadem script seem to require the specific file names to load where I would just like to load all that is found in folder.
Thanks for any thoughts or suggestions.
BG103
04-16-2015 02:32 PM - edited 04-16-2015 02:33 PM
Hello BG103
I use "FileNameGet" Command. But the catch is you have to select multiple files manually ( Cntr+A for all files).
If (FileNameGet("ANY", "FileRead", DataReadPath, "TDMS data (*.tdms),*.tdms", "All.lst", True, "Data selection")= "IDOk") Then
Call DataFileLoad(FileDlgFileName,"TDMS")
End if
Try this
Thanks
Arun
04-17-2015 12:58 AM
Hi,
i think that selecting the folder and automatically load the contained files is the better way:
'Simple way Call PathNameGet("Select measurement folder", DataReadPath) If (DlgState = "IDOk") Then DataReadPath = OutPutPath vValues = DirListGet(DataReadPath, "*.*", "filename", "FullFilenames") For iCount = LBound(vValues) To UBound(vValues) Call DataFileLoad(vValues(iCount)) Next End If 'more complicated way, but here you can select multiple file extensions 'Constant for defining the loadable file extensions Const FILEDATA = "*.tdm|*.dat" 'Select folder Call PathNameGet("Select measurement folder", DataReadPath) If (DlgState = "IDOk") Then DataReadPath = OutPutPath vValues = getRawData(DataReadPath, FILEDATA, "", "") For iCount = LBound(vValues) To UBound(vValues) Call DataFileLoad(vValues(iCount)) Next End If 'Functions for getting the files Function getRawData(dataPath, dataName, sortType, lstFilter) Dim mySrtType : mySrtType = "filename" Dim myLstFilter : myLstFilter = "FullFileNames" Dim vDataName, vFileData, vTemp Dim i, j, k If (sortType <> "") Then mySrtType = sortType End If If (lstFilter <> "") Then myLstFilter = lstFilter End If k = 0 Set vFileData = CreateObject("Scripting.Dictionary") vDataName = Split(dataName, "|") If IsArray(vDataName) Then For i = LBound(vDataName) To UBound(vDataName) vTemp = DirListGet(dataPath, vDataName(i), mySrtType, myLstFilter) If IsArray(vTemp) Then For j = LBound(vTemp) To UBound(vTemp) ' has to be checkt because DirListGet gets with Filter *.tdm also tdms ' and tdms_index data If (getFileType(vTemp(j)) = getFileType(vDataName(i))) Then Call vFileData.Add(k, vTemp(j)) k = k + 1 End If Next End If Next End If If (vFileData.Count > 0) Then getRawData = vFileData.Items Else getRawData = EMPTY End If End Function Function getFileType(sFile) If (InStrRev(sFile, ".") <> 0 AND Len(sFile) > 0) Then getFileType = UCase(Right(sFile, Len(sFile) - InStrRev(sFile, "."))) Else getFileType = "" End If End Function
04-17-2015 08:34 AM
Thank you kindly both for your responses. They have each helped me!