Sort cards Numeric by (a mixed string)
Cubist at aol.com
Cubist at aol.com
Sun Jun 6 18:51:06 EDT 2004
sez katir at hindu.org:
>Is there a way to force Rev to see a mixed alpha numeric string as
>numeric if it begins with numbers?
I don't see how Rev *can* treat a mixed alpha-numeric string as numeric.
If the only alpha characters are found in "abcdef", then you could get away
with treating the string as hexadecimal; but if the string contains X or Z or K
or whatever else, you're probably screwed.
>Context: series of cards auto loaded with images where the field
>"photofileName" comes in and the image ref for image 1 on the card is
>the same.
>
>e.g.
>card no fld "photoFileName"
>card 1 1.BigBlueBird
>card 2 10.RedOrange
>card 3 11.WhiteApple
>card 4 2.SmallBlackBird
>
>Ideal the person naming the photos uses zero padding, but typically I
>find users oblivious to this issue and I simply need to give them a way
>to resort from a button to:
>
>card 1 1.BigBlueBird
>card 2 2.SmallBlackBird
>card 3 10.RedOrange
>card 4 11.WhiteApple
>
>Sort cards of this stack numeric by fld "photoFileName"
>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....
Maybe something like this might work?
set the itemDelimiter to "."
sort cards of this stack by (item 1 of the name of each card)
This is off the top of my head, so I've probably mangled the syntax
horribly, but perhaps the basic idea will prove sound. Hope this helps...
More information about the use-livecode
mailing list