Sort cards Numeric by (a mixed string)
briany at qldlearning.com
Sun Jun 6 18:02:13 CDT 2004
>> does nothing... no error, no resort... I assume because the mixed
>> strings cannot be evaluated as numbers...
>> What would be a work around...?? I could use some complicated parsing
>> routine but it would fail if another user decided to use a different
>> delimiter (in this case he's used a dot), so I need a global solution
>> that says to Rev -forget the alpha characters at the end of the
>> string, just use the numbers at the beginning. iViewMedia does this
>> automatically in its catalog system... i.e. it assumes if there are
>> numbers at the beginning to sort by numbers and "10*alphaChars"
>> follows "9*alphaChars", not "1*alphaChars" in any listing....
Here's one that's not too complicated:
put fld "photoFileName" into pFileName
## extract the numeric prefix
put empty into numericPrefix
repeat for each char c in pFileName
if (c is a number) then
put c after numericPrefix
## remove it from the original
if (numericPrefix is not empty) then delete char 1 to
length(numericPrefix) of pFileName
## pad it with zeros
repeat until length(numericPrefix) = 5
put "0" before numericPrefix
## put it back on
put numericPrefix before pFileName
put pFileName into fld "photoSortField"
sort cards ... by fld "photoSortField"
More information about the use-livecode