Mator

[Pascal] [xEdit] List records by group

Jul 27th, 2015
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.34 KB | None | 0 0
  1. {
  2.   List records from a group in the user's load order
  3.   Created by matortheeternal
  4. }
  5. unit userscript;
  6.  
  7. const
  8.   // if save is true, a text file will be saved with the list  
  9.   // of records in the group
  10.   save = true;
  11.   // if print is true, the list of records will be printed directly
  12.   // to xEdit's log
  13.   print = true;
  14.   // if masterOnly is true, override records will be ignored
  15.   // (so only the base record gets listed)
  16.   masterOnly = true;
  17.  
  18. function Initialize: integer;
  19. var
  20.   i, j: integer;
  21.   f, g, e: IInterface;
  22.   s: string;
  23.   sl: TStringList;
  24. begin
  25.   sl := TStringList.Create;
  26.   s := InputBox('Group Signature',
  27.     'Enter the signature of the group of records you want to list',
  28.     'INGR');
  29.   AddMessage('Listing '+s+' records...'#13#10);
  30.  
  31.   for i := 0 to FileCount - 1 do begin
  32.     f := FileByIndex(i);
  33.     g := GroupBySignature(f, s);
  34.     if not Assigned(g) then continue;
  35.     sl.Add(Format('%s [%d]', [GetFileName(f), ElementCount(g)]));
  36.     for j := 0 to Pred(ElementCount(g)) do begin
  37.       e := ElementByIndex(g, j);
  38.       if not masterOnly then
  39.         sl.Add('  '+Name(e))
  40.       else if Equals(e, MasterOrSelf(e)) then
  41.         sl.Add('  '+Name(e));
  42.     end;
  43.     sl.Add(' ');
  44.   end;
  45.  
  46.   if print then AddMessage(sl.Text);
  47.   if save then sl.SaveToFile('List of '+s+' records.txt');
  48.   sl.Free;
  49. end;
  50.  
  51. end.
Advertisement
Add Comment
Please, Sign In to add comment