DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Load/Sort files like Windows - by name (there's a little difference)

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

0 Kudos
Message 1 of 4
(3,050 Views)

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

0 Kudos
Message 2 of 4
(3,034 Views)

@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).

0 Kudos
Message 3 of 4
(3,029 Views)

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

0 Kudos
Message 4 of 4
(3,018 Views)