DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

All.lst is created when FileNameGet is called

I am calling FileNameGet() in a SUD Dialog, which allows a user to select multiple files.  This call then sets the returned values to the T1 global variable, so I can work on the files in a Diadem script. 

However, when this function is called and the file names returned, a All.lst file is created in directory, which is defined in the DIAdem Menu selection:

Settings->Options->SCRIPT

dialog as the SCRIPT user path: setting. 

Is it possible to use FileNameGet() without creating the All.lst file? 

Thanks. 
0 Kudos
Message 1 of 6
(4,500 Views)
Hello Rich!

If you set the 6th Parameter to an empty string it should work.

Example code (from help, edited): Call FileNameGet("ANY","FileRead","C:\","TDM data (*.tdm),*.tdm", "", True, "Data selection")

Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 6
(4,490 Views)
Yes, I believe that is it, although I believe it is the 5th parameter, not the sixth.  I missed that in the Help.

Once I remove the All.lst file name from that location, it will only let me choose one file then.  Helpfull for the one file selection dialogs, but in this case I want to be able to choose a lot of files.
0 Kudos
Message 3 of 6
(4,490 Views)
Hello Rich!

Yes, the ',' in the filter confused my counter. It's the 5th parameter.

Unfortunately it is (as I know) necessary to use the file list feature if you want to get a multi select file select box. Here is a small function solving this task:
Function MultiFilenameGet(ByRef sgPath, ByRef sgFilter, ByRef sgTitle)
Dim sgFilenameList
Dim oFile
Dim asgFilenames
 
sgFilenameList = GetEnv(
"Temp") & "\FilenameGet.lst" ' temporary list file in TEMP folder
asgFilenames = Array()
 
' select files
Call FileNameGet("ANY","FileRead", sgPath, sgFilter, sgFilenameList, True, sgTitle)
 
If UCase(DlgState) =
"IDOK" Then
Set
oFile = CreateObject(
"Scripting.FileSystemObject").OpenTextFile(sgFilenameList,,,-2)
 
Do While oFile.AtEndOfStream <> True
' read single filename and store it in a dynamic growing array
ReDim Preserve asgFilenames(Ubound(asgFilenames)+1)
asgFilenames(Ubound(asgFilenames)) = oFile.ReadLine()
Loop
 
' release file so we can delete it
oFile = Empty
Call
FileDelete( sgFilenameList )
End If
 
' return filename array (empty if dialog is canceled)
MultiFilenameGet = asgFilenames
End Function

Testcode for this function:
Dim asgFilenames
Dim sgFilename
 
asgFilenames = MultiFilenameGet(
"D:\Programme\National Instruments\DIAdem 9.1\Libr\Dat\","TDM data (*.tdm),*.tdm", "Data selection")
 
MsgBox Ubound(asgFilenames)+
1 & " Files selected"
 
For Each sgFilename in asgFilenames
MsgBox sgFilename
Next

Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 4 of 6
(4,483 Views)
My Solution for Multifileselection without creating a File. May by it helps.
 
 
Call FileNameGet("any", "FileRead","C:\Messdaten\","(*.DAT),*.DAT,(*.TDM),*.TDM","nul",True)
FileNames = Split(FileDlgFileName,"|")
 
For n = Lbound(FileNames) To Ubound(FileNames)
  Call DoAnythingWith(Filesnames(n))
Next

Message Edited by OWitter on 09-29-2006 04:20 AM

0 Kudos
Message 5 of 6
(4,470 Views)

Wow OWitter!!

That's brilliant!!  How long has this been possible with DIAdem?  How did you find this out?

I'm jealous and thankful,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 6 of 6
(4,461 Views)