Page 1 of 1

Sort->MediaLabel

Posted: 2007-02-27 12:43:33
by Scriabin
Hi all first, this is my debut in this forum.
Let's see my problem: it happens when I try to sort my database by MediaLabel variable.
here's the screenshot:

Image

The numbers are not ordered as you can see: 10 must be after 9 and not just after 1, the same for 100...it should be after 99 but it's just after 10.
If I try to export the database I obtain the same type of sorting.
I need it to be 1-2-3.....9-10-11.....99-100-101.... and not 1-10-100-101...and so on.
what's wrong?

Posted: 2007-02-27 13:26:31
by bad4u
Nothing's wrong ;)

I think it is because MediaLabel is no 'integer' but some kind of 'string' variable, and then it is the normal behaviour. In MediaType field you cannot use numbers only, but all kind of letters. Sorting will start with the first letter of the word (or integer), then read the second one, third one - and so on.

You should add some leading '0' if you want to get a proper listing.

001
002
...
010
011
..

But maybe I'm wrong and there is a better solution ? ;)

Posted: 2007-02-27 13:59:31
by Scriabin
it's a hard hard work...I have to change my over three hundred labels in something like 0001-0002...? :cry:
I hope there's a better solution...

Posted: 2007-02-27 19:18:49
by antp
This can be done easily using a script, I think that I posted that somewhere on the forum some time ago.
I do not have time right now, I'll post it within 1h if you haven't found it until then.

Posted: 2007-02-27 20:13:12
by Scriabin
I've tried a lot of searches in this forum, maybe the wrong words...
Thanks in advance for your help
:D

Posted: 2007-02-27 20:29:07
by antp
OK so here is it:

Code: Select all

program NewScript;
var
  s: string;
begin
  s := GetField(fieldMedia);
  if s <> '' then
  begin
    while Length(s) < 4 do
      s := '0' + s;
    SetField(fieldMedia, s);
  end;
end.
Go to tools -> scripting, or press F6.
Be sure that in "script limitations" you have checked "all" (or "selected" if you want to modify only the selected movies).
In the "editor" tab click the "new" icon and replace the script template by the one above.
The click run and it should be done ;)
(you can reply "no" when the program asks if you want to save the script, except if you want to reuse it later)

Posted: 2007-02-27 20:56:22
by Scriabin
Wonderful, it works!!!!!!!!!!!!! :clapping: