08-09-2007 09:05 PM
08-10-2007 03:24 AM
08-10-2007 06:47 AM
Ingo
Thanks for the reply and if that is actually how the function worked then I would be satisfied. However, it does not load the file (or even save them to the .lst file) in the same order as I select them from the dialog box.
In the attachement I show the dialog box that is opened when the FileNameGet function is used and I select the files sequentially in order Mod1-08-01-07.dat, Mod1-08-02-07.dat, and finally Mod1-08-03-07.dat. However, the files are loaded as Mod1-08-03-07.dat, Mod1-08-01-07.dat, Mod1-08-02-07.dat (also the .lst file is attached which shows the same thing although I changed the extension to .txt so it could be attached).
Like I stated above, if it did load the files as I selected them all would be great and that is how I expected it to work. I would hate to have to write a bunch of code to somehow sort the filenames to overcome the odd behavior of this function so any help anyone has would be appreciated.
08-10-2007 07:01 AM
Matthias Alleweldt Project Engineer / Projektingenieur | Twigeater? |
08-10-2007 07:03 AM
08-10-2007 07:22 AM
08-10-2007 07:42 AM
Option Explicit 'Forces the explicit declaration of all the variables in a script.
'-------------------------------------------------------------------------------
' Sorts a listfile alphabetically
'-------------------------------------------------------------------------------
function sort(Listfile)
dim line, file, files()
' Read LST file into files() variable, remove header comments
dim buffer
line = 0
file = TextFileOpen(Listfile,tfRead)
Do While Not TextFileEOF(file)
buffer = TextFileReadLn(file)
if left(buffer,1) <> "{" then
line=line+1
redim preserve files(line)
files(line) = buffer
end if
Loop
textfileclose file
' Bubblesort
dim done, tmp, i, j
For i = 1 To ubound(files)
do
done = True
For j = 1 To 6
If files(i) < files(j) Then
done = False
tmp = files(i)
files(i) = files(j)
files(j) = tmp
End If
Next
loop until done
Next
' Rewrite LST file
file = TextFileOpen(Listfile,tfCreate OR tfWrite OR tfANSI)
For line = 1 to ubound(files)
TextfileWriteLn file, files(line)
Next
textfileclose file
end function
'-------------------------------------------------------------------------------
' MAIN
'-------------------------------------------------------------------------------
sort autoactpath&"list.lst"
08-10-2007 02:14 PM
Hi Guys,
This is an old problem in DIAdem. Here is the solution that I always use, which simply alphabetizes the selection by file name, which is usually what the user is intending. Note that I am patently ignoring the LST file and relying on the "FileDlgFileName" variable, which is filled by the FileNameGet() function in most modern DIAdem versions. If you happen to have an older DIAdem version, I can send you my previous function, which actually reads in the LST file contents in order to re-order the file names alphabetically.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-10-2007 02:21 PM
Brad / Ingo
Thanks to both of you for your help. Rather than using the filesystem object as Ingo suggested, I actually used a bubble sort routine obtained from a coworker (actually looks identical to yours Brad)after selecting the filenames and this takes cares of what I was trying to accomplish. Thanks again!
09-26-2007 08:50 AM
Hello,
Why you are taking more efforts to get the file in order? There are two simple ways available without doing the script.
1. Arrange the filename by name
2. When selecting the file, notice below the filenames in the filename box. It Looks first in lastout register.
Thank you