DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to automatically load datas from several files of an header file?

Hi,
I have to realize an automatic files treatment to generate Statistics, and first i must create an automatic datas loading for each file of an header file. 
 
Could you help me?
0 Kudos
Message 1 of 6
(4,080 Views)
Hi K9,

To load files via script you can use the command FileNameGet. Please have a look into the DIAdem help to get more detailed info. In general the easiest way to start with a script is the recording mode in the Panel Script of DIAdem. If you start the recording mode DIAdem records all necessary commands in the script editor. After finishing the recording you can modify and customize the VBScript.

Greetings

Walter
0 Kudos
Message 2 of 6
(4,069 Views)

Hi,

Thanks Walter.

But I don't want to open a dialog box for loading datas manually (with the FileNameGet command), I want an automatic loading of datas files by indicating a directorie in the diadem script.

Do you know the exact command?

0 Kudos
Message 3 of 6
(4,059 Views)
Hi,

Please have a look at the DIAdem example "Serial Evaluation".

Greetings

Walter
0 Kudos
Message 4 of 6
(4,056 Views)
Hi K9,
 
Walter's suggestion is to use the DIAdem command "DirLstWrite()" to create an ASCII file with the names of the files in a particular directory, then use serial evaluation to sequentially load and analyze those files, using the ASCII file to determine which data files to load.
 
There are cases where serial evaluation is not flexible enough-- you might, for instance, want to load all the data files at once and calculate some statisical quantities which cut across all the data files.  For this case, you can either read in the ASCII file generated with the "DirListWrite()" command, or you can use the following VBScript functionality to get a (1-indexed) array of the file paths within a particular start directory:
 
StartDir = "C:\"
FileExts = "txt|asc|dll" ' example list of selected file extensions
FileExts = "*"
FilePaths = FileListInDir(StartDir, FileExts)
MsgBox Join(FilePaths, vbCRLF)

'-------------------------------------------------------------------------------------
'******* FileListInDir() ***                                      *** NEW Function ***
'-------------------------------------------------------------------------------------
Function FileListInDir(Directory, FileExtStr)
  Dim k, f, fc, fso, file, ExtComp, ExtStr, DotPos, FileListStr, FileExts
  FileExts = Split("|" & FileExtStr, "|")
  Set fso = CreateObject("Scripting.FileSystemObject")
  If Not fso.FolderExists(Directory) Then FileListInDir = Array("") : Exit Function
  Set f = fso.GetFolder(Directory)
  Set fc = f.Files
  FOR k = 1 TO UBound(FileExts)
    ExtComp = UCase(Trim(FileExts(k)))
    For Each file In fc
      DotPos = InStrRev(file.Name, ".")
      ExtStr = UCase(Trim(Mid(file.Name, DotPos+1)))
      IF ExtStr = ExtComp OR ExtComp = "*" THEN
        FileListStr = FileListStr & "|" & file.Path
      END IF
    Next ' file
  NEXT ' k
FileListInDir = Split(FileListStr, "|")
End Function ' FileListInDir()
 
Hope that helps,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 5 of 6
(4,040 Views)
Thanks for your help Brad and Walter,
 
Your script doesn't work yet Brad, I must have to modify it more.
I found a good exemple to load Ascii datas from several files into the link http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=C34F36CBFA7173C3E034080020E74861.
 
Greetings,
 
K9.
0 Kudos
Message 6 of 6
(4,028 Views)