01-19-2017 03:26 AM
If I try to load data via Code, i don't get the same sorting Result as in Windows (7 64bit).
The Data looks like:
18.01.2017_1.tdms
18.01.2017_2.tdms
...
18.01.2017_10.tdms
18.01.2017_11.tdms
and in DIAdem the Data is sorted like:
18.01.2017_1.tdms
18.01.2017_10.tdms
18.01.2017_11.tdms
...
18.01.2017_2.tdms
Here's the code:
fileList = DirListGet(Pfad_Daten_ + "Measfiles","*.tdms","filename","FullFilenames")
If IsArray(fileList) Then
For iCount = Lbound(fileList) to Ubound(fileList)
Call DataFileLoad(fileList(iCount),"TDMS","Load") 'File laden
Next
End If
Also i don't know why the dot is also in the Packagename after import (ex: "18.01.2017_11." from file "18.01.2017_11.tdms")
Thanks for help
01-23-2017 04:48 PM
Hi mich,
The file list you say you see in Windows Explorer must be sorted by some other field (I'm guessing datetime). The file list you see sorted in DIAdem is the correct ASCII string sorting, because "2" > "10" as a string comparison. If you'll submit the TDMS file that gives you that trailing period, I'll be happy to look at it.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
01-24-2017 12:37 AM
@KUDOS:
Thanks for your answer. I thought that too, but you can check it with creating 5 Files/Folders ("1", "2", "10", "15", "20"). These are sorted correctly (Win 7 Enterprise SP1, 64bit).
01-24-2017 01:43 PM
Hi mich,
Well that's an interesting development. Windows behavior aside, DIAdem still sorts strings alphabetically, according to the ASCII table. In order to sort a set of strings by the numeric value of the last part of each string, you would need to create a parallel array of that last part of each string, then perform numeric comparisons to do the ordering of both arrays simultaneously. Here's an example of a simple bubble sort approach:
NamesToSort = Array("Name_1", "Name_10", "Name_15", "Name_20", "Name_2") NumsToSort = Array(1, 10, 15, 20, 2) Call BubbleSortNums(NamesToSort, NumsToSort) MsgBox Join(NamesToSort, vbCRLF) Sub BubbleSortNums(NamesToSort, NumsToSort) Dim i, SwapName, SwapNum, Swapped Do ' Until bubble sort of NamesToSort() is finished Swapped = False FOR i = 0 TO UBound(NamesToSort)-1 IF CDbl(NumsToSort(i)) > CDbl(NumsToSort(i+1)) THEN SwapName = NamesToSort(i) SwapNum = NumsToSort(i) NamesToSort(i) = NamesToSort(i+1) NumsToSort(i) = NumsToSort(i+1) NamesToSort(i+1) = SwapName NumsToSort(i+1) = SwapNum Swapped = True END IF ' Name(i) and Name(i+1) need to be swapped NEXT ' i Loop Until NOT (Swapped) End Sub ' BubbleSort()
Brad Turpin
DIAdem Product Support Engineer
National Instruments