07-25-2022 05:45 AM
Hello guys.
During our tests we record the data mostly in blocks, and concatenate them later.
Before this concatenation, the order of the loaded files should be checked/corrected.
In several topics here the bubble sorting is mentioned; in my case the result doesn't solve the problem:
This is the result of such bubble sorting (not all groups are listed here, just few to show the problem).
The first block has no "_index" suffix (this is correct and comes in this way out of our data recording).
But then indices goes according the numbers, and this is not exactly correct.
The only one way I see is to load all files, adjust the group names (i.e. number of digits) and sort then.
Means, go through all groups, and change "_index2" to "_index_02" etc.
Check, if "_index100" exists; because then I need 3 digits...
Logically clear, but I'm awared about the possible mistakes.
Does anybody have a similar issue, and solved it in a different way?
Thanks,
Vassili
Solved! Go to Solution.
07-25-2022 10:04 AM
The easiest way would be to create the indices with leading zeros, so instead of index1, you have index001. This is the easiest since text sorts are alphabetic.
Here is a simple example that adds leading zeros.
Option Explicit 'Forces the explicit declaration of all the variables in a script.
dim sString
sString = "-0101-7391-11_index1"
msgbox(AddLeadingZero(sString))
function AddLeadingZero(MyString)
Dim SplitString, indexnumber
SplitString = Split(MyString,"index",-1,vbtextcompare)
indexnumber = Cint(SplitString(Ubound(SplitString)))
AddLeadingZero = SplitString(0) & "index" & str(indexnumber,"0ddd")
end function
07-26-2022 09:49 AM
Thanks, interesting function!
Needed to modify the last line slightly; otherwise my Diadem doesn't understand the format "0ddd":
AddLeadingZero = SplitString(0) & "index" & REPLACE(str(indexnumber,"dddd"), " ", "0")
I did it in much more complicated way.
Thank you for improvement!