I am trying to write a script to add the next highest unique number to a field. Say I have 100 movies, half online (on HDD), half offline (DVDs). I want to use a field (say source) to add the next highest unique number to that field so I can use that number to ID the DVD so I can find it when I want it. In this case, the next movie number would be 101, but the next DVD number would be 51.
Getting the next highest unique number (no sorting needed) is easy enough eg:
Code: Select all
var
curNum: Integer;
maxNum: Integer;
nextNum: Integer;
begin
begin
curNum := StrToInt(GetField(fieldSource), 0);
if curNum > maxNum then maxNum := curNum;
nextNum := maxNum + 1;
if GetIteration() = GetIterationCount() - 1 then ShowMemo('nextNum: ' + IntToStr(nextNum));
end;
//write the nextNum to the current movie
end.
I have considered but been unable to achieve any of these solutions:
(a) select only one movie but have the above (as a function) run on all movies (add a line to tell it to run on all movies, not just the selected movie?)
(b) select all movies but somehow mark or flag or store in a variable the one which is to be written to
(3) select one movie but then read the (xml format) catalogue file directly and put the source field entries into an array and sort/get highest value. Have tried to make sense of how to do xml in Pascal but it makes my head hurt...
Any ideas?
Thanks in advance.